I have a set of regular expressions inside a function that works pretty well for me, but I came across a new pattern where they fail. This function does not work when there are more characters in the string. For example, my function matches and replaces the text as follows: " 1 m is equivalent to... " becomes " 1 meter is equivalent to... " However, it does not work: " There are 100 cm in 1 m "
I am using AS3, which I assume has a regex mechanism, almost equivalent to JavaScript. Current template:
[0-9]+ m(?= )|[0-9]+m(?= )
I am looking at a list of patterns and replacement strings, so it was easy to add another pattern to the list. I tried:
[0-9]+ m(?=)|[0-9]+m(?=)
and
[0-9]+ m(?='')|[0-9]+m(?='')
And both failed. I lack the fundamental brevity of knowledge. I believe that I need to know how to say: "look ahead and match when there are no other characters in the string"
user56512
source share