String Pattern

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was wondering if anyone could explain what exactly this pattern means?

oRE.Pattern = "\b.{0,1500}(?:\W|$)"

Thanks.
-State
 
\b at the beginning of the pattern means "start matching at a word
boundary".

.. matches any single character

..{0,1500} means "match as many characters as you can but not more than
1500 of them"

(?: ) means "group this subpattern as if it was in ( ), but don't save
whatever it matches

\W matches any "non-word" character (e.g. anything but 0-9,A-Z,a-z_)
| means "or"
$ means the end of the string.

So given a string like this "Hello world lots and lots of words....."
the pattern will start with the boundary at the beginning of "Hello" and
match up to 1500 characters, stopping at the end of the string or at the
last non-word character before the 1501st character, whichever comes
first. If oRE.Global is true, successive matches will start where the
previous match ended.
 

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

Similar Threads

Computer Crashing 8
regular expression 7
regex pattern 4
regex pattern 2
what happened to pattern fills in Powerpoint 2007? 4
Regex Pattern 11
Regular Expression Pattern 7
NET Regular Exp patterns work in VB6? 2

Back
Top