我将尝试在JavaScript中匹配最后一个字符串(但不包括它本身)之后的所有内容。
例如,搜索如下:
例如,搜索如下:
[quote="user1"]this is the first quote[/quote]\n[quote="user2"]this is the 2nd quote and some url https://www.google.com/[/quote]\nThis is all the text I\'m wirting about myself.\n\nLook at me ma. Javascript.
编辑:我想要匹配最后一个引用块之后的所有内容。所以我正在尝试匹配最后一次出现的“quote]”之后的所有内容?我不知道这是否是最佳解决方案,但这是我一直在尝试的。
说实话,我对这个正则表达式的东西不太擅长...下面是我一直在尝试的结果...
regex = /(quote\].+)(.*)/ig; // Returns null
regex = /.+((quote\]).+)$/ig // Returns null
regex = /( .* (quote\]) .*)$/ig // Returns null
我已经为大家做了一个JSfiddle,大家可以在这里尝试一下: