Regular Expressions: An Introduction
by Amit Arora
Published: January 12, 2004
User Rating: 8.9 (282 votes)

Page Page » 1 2 3 4 5 6 7 8 9

Positional Matching

Positional matching allows you to match the pattern with the start and end of the subject.

  • ^: Match Start of the subject (or start of the line, in multi-line mode)
  • $: Match End of the subject (or end of the line, in multi-line mode)
  • \A: Match Start of the subject (independent of multi-line mode)
  • \z: Match End of the subject (independent of multi-line mode)

Taking a few examples

Regex /.*abcd.*/ Equivalent to /abcd/ Explaintaion Match anything, followed by "abcd", followed by anything Regex /^abcd.*/ Explaintaion Match starting "abcd", followed by anything Example abcd True abcde True abcdef True xyzabcd False xyzabcdef False Regex /abcd$/ Explaintaion Match ending "abcd" Example abcd True abcde False abcdef False xyzabcd True xyzabcdef False Regex /^abcd$/ Explaintaion Match starting and ending "abcd" Example abcd True abcde False abcdef False xyzabcd False xyzabcdef False
Page Page » 1 2 3 4 5 6 7 8 9

About

Amit Arora is web developer with expertise in developing eCommerce enabled websites for the businesses.

Contact | Resume

Subscribe to newsletter




Get Firefox

Monitored by Site24x7
Uptime