Javascript regex does not match last char in form

I have this simple regular expression to catch the last instance of "turn to 123" in the form (I have another regular expression for the main body):

currenttext=currenttext.replace(/([^>])(turn\s+to\s+)(\d+)$/i,"$1<tt ref=\"$3\">$2$3</tt>");

which, for example, replaces turn to 123 ... with

<tt ref="123">turn to 123</tt>...

... in live mode. However, it only works if there is a form character after number 123, whether it is a carriage return or a visible character that I cannot understand, since the $ end of match binding clearly does not have another character before the memory pattern for numeric digits. Without the following character, I get this result:

<tt ref="12">turn to 12</tt>3

i.e. he cannot catch the last digit completely. I tried putting $ anchor inside the memory folders, but it didn't make any difference.

+5
source share
1

, . currenttext. , ( console.log( ), alert ( ), - ).

:

  • (...) (begin, end) (begin, end + 1)?
  • RegExp?
+2

All Articles