javascript 拆分正则表达式
javascript split regular expression
当给定一个字符串时,例如:
daily (similar term)|day-to-day (similar term)|day-after-day (similar term)|every day (similar term)|nightly (similar term)|first-string (similar term)|lawful (similar term)|orderly (similar term)|rule-governed (similar term)|official (similar term)|prescribed (similar term)|regularized (similar term)|regularised (similar term)|routine (similar term)|standard (similar term)|stock (similar term)|timed (similar term)|uniform (similar term)|weak (similar term)|well-ordered (similar term)|rhythmical (related term)|rhythmic (related term)|symmetrical (related term)|symmetric (related term)|systematic (related term)|irregular (antonym)veritable|typical (similar term)standard (similar term)irregular (antonym)scheduled (similar term)usual (similar term)even|steady (similar term)steady|frequent (similar term)standing (similar term)|irregular (antonym)unconstipated|diarrheal (similar term)|diarrhoeal (similar term)|diarrhetic (similar term)|diarrhoetic (similar term)|diarrheic (similar term)|diarrhoeic (similar term)|lax (similar term)|loose (similar term)|constipated (antonym)even|symmetrical (similar term)|symmetric (similar term)normal (similar term)full-time (similar term)habitue|fixture|patron|frequentersoldierfollowersize
如何创建同义词数组,例如
var thisArr = ['daily', 'day-to-day', 'day-after-day', 'every day', 'nightly']
等,但在它说 'irregular (antonym)' 的地方,我不想包括任何别名(在本例中为 'irregular')。可以包含其他词(不是括号中的词)。但我不想要“|”字符,或括号。我试过了
var thisRegExp = /\|(.*?)\|/;
我可以删除“|”得到,例如
"day-to-day (similar term)"
但我也想删除括号内的内容,我猜想删除括号旁边的任何空格,因为它们不会成为 'word pairs' 的一部分。非常感谢任何帮助。谢谢,MediaMaker。
您可以使用正则表达式:
([^|()]+)(?= \(similar term|\||$)
([^|()]+)
- 一个或多个字符,但不匹配 |
、(
、)
|
到括号 之间的单词
(?= \(similar term|\||$)
- 正面前瞻(类似术语),
或 |或字符串结尾,只匹配相似的词或没有
括号中的描述
获得相似(没有 (similar word)
)或未描述的词。
当给定一个字符串时,例如:
daily (similar term)|day-to-day (similar term)|day-after-day (similar term)|every day (similar term)|nightly (similar term)|first-string (similar term)|lawful (similar term)|orderly (similar term)|rule-governed (similar term)|official (similar term)|prescribed (similar term)|regularized (similar term)|regularised (similar term)|routine (similar term)|standard (similar term)|stock (similar term)|timed (similar term)|uniform (similar term)|weak (similar term)|well-ordered (similar term)|rhythmical (related term)|rhythmic (related term)|symmetrical (related term)|symmetric (related term)|systematic (related term)|irregular (antonym)veritable|typical (similar term)standard (similar term)irregular (antonym)scheduled (similar term)usual (similar term)even|steady (similar term)steady|frequent (similar term)standing (similar term)|irregular (antonym)unconstipated|diarrheal (similar term)|diarrhoeal (similar term)|diarrhetic (similar term)|diarrhoetic (similar term)|diarrheic (similar term)|diarrhoeic (similar term)|lax (similar term)|loose (similar term)|constipated (antonym)even|symmetrical (similar term)|symmetric (similar term)normal (similar term)full-time (similar term)habitue|fixture|patron|frequentersoldierfollowersize
如何创建同义词数组,例如
var thisArr = ['daily', 'day-to-day', 'day-after-day', 'every day', 'nightly']
等,但在它说 'irregular (antonym)' 的地方,我不想包括任何别名(在本例中为 'irregular')。可以包含其他词(不是括号中的词)。但我不想要“|”字符,或括号。我试过了
var thisRegExp = /\|(.*?)\|/;
我可以删除“|”得到,例如
"day-to-day (similar term)"
但我也想删除括号内的内容,我猜想删除括号旁边的任何空格,因为它们不会成为 'word pairs' 的一部分。非常感谢任何帮助。谢谢,MediaMaker。
您可以使用正则表达式:
([^|()]+)(?= \(similar term|\||$)
([^|()]+)
- 一个或多个字符,但不匹配|
、(
、)
|
到括号 之间的单词
(?= \(similar term|\||$)
- 正面前瞻(类似术语), 或 |或字符串结尾,只匹配相似的词或没有 括号中的描述
获得相似(没有 (similar word)
)或未描述的词。