What about ^0, $ in Regular expression

  • Thread starter Thread starter ad
  • Start date Start date
If I were searching for 'abc' and I did not have ^ and $ it would find it
would find it in the middle of strings, that is at any position in the string.

The ^ means it must start with the first character of the string to be
searched and the $ that it must be the ending character of the searched text.




ad said:
What make difference if we omit ^ or $ at begin and end?

Phil said:
pretty sure that ^ is beginning of line and that $ is end.


ad said:
I found a Regular expression in
http://www.regexlib.com/DisplayPatterns.aspx?cattabindex=6&categoryId=7What
do the ^0, $ mean in the begin and end of Regular
expression?^0[234679]{1}[\s]{0,1}[\-]{0,1}[\s]{0,1}[1-9]{1}[0-9]{6}$
 
Valid entries for: ^0[234679]{1}[\s]{0,1}[\-]{0,1}[\s]{0,1}[1-9]{1}[0-9]{6}$
would be:
02-1000000
021000000
021999999
02-8888888

However each number must be the complete string. i.e. '02-8888888' not
'02-8888888 ' a space at the end or ' 02-8888888' a space at the begining.

The ^0 means it must start with a zero. The bracketed [2-9]{1} means that
you must have one character following it that is any character 2 through 7,
etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top