Jump to content
Larry Ullman's Book Forums

Format Of End Of Regular Expressions


Recommended Posts

Hello everyone

 

I see that regular expressions in the book usually end with /i

e.g.

'/^[A-Z0-9\'.-]{2,30}$/i'

 

However, on page 86 under point 7, the i is left off after the end forward slash:

'/^(\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*){6,20}$/'

 

Why has the i been left off in this instance?

 

Regards,

Warwick

Link to comment
Share on other sites

Welcome to the forum, Warwick.

 

The regex itself actually ends at the forward slash. The i after the forward slash is one of many possible modifiers that affects the entire regex. Specifically, the i meaning that the regex should search for strings in a case-insensitive fashion. The other common modifier you see for regexes is g, which is used for global searches (i.e., don't stop after the first match).

 

While for JavaScript, the following link might shed some light on things:

http://www.w3schools.com/jsref/jsref_obj_regexp.asp

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...