I'm trying to match a * xxx pattern like "* test", "* love" "* some Also "(such as hashtags)
I originally tried:
" aaa * eee * rrr * ttt ". Match (/ (\ s | ^) (\ * [a-Z0-9] {3,150}) (\ s | $) / img) Returns only strange logical matches: "AAA" and "* RRR"
When matching, I think that the engine "points" is called the whole match point as "experiment" and hence is removed from the test to the next block . And so, what can be the "nothing" digit, because "^" has not been started, and the second is not anything before the match.
Is there any idea to fix this?
Try it out:
/ (?: ^ | \ ) (\ * [A-z0- 9] {3,150}) (? = $ | \ S) / gim
Usage:
var match, regex = / (?: ^ | \ S) (\ * [a-z0- 9] {3,150}) (? = $ | \ S) / gim while (match = regex.exec ("* aaa * eee * rrr * ttt * xxx @ hhh * iii * uuu * ooo * www")) {console.log (match [1]); } Output (match "tag"):
* aaa * eee * rrr * ttt * www
No comments:
Post a Comment