www.webdeveloper.com
Results 1 to 2 of 2

Thread: regular expression

Hybrid View

  1. #1
    Join Date
    Apr 2011
    Posts
    7

    regular expression

    what is this means?

    /^((\w+)|(\\.))+$/

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,276
    /^((\w+)|(\\.))+$/

    This regular expression is made to capture fully formed chains (^ assert start of subject and $ assert end of subject) from one or more sub-pattern delimited by the external round brackets followed by the plus sign ( sub-pattern )+.

    The sub-pattern includes two alternative sub-patterns (the vertical bar characters separates alternative sub-patterns) the first (\w+) capture one or more "word" character and the second capture one backslash (the \ preceding an other \ specify that the second one stands for itself) followed by any character (the point .). But this last sub-pattern seems very strange ???

    See for example this ECMAScript regular expressions pattern syntax page

    Otherwise, it would be more efficient to specify the patterns you want to capture, to build an adapted regular expression...

    EDIT : Then this expression capture the string : 'John\jPaul\p' as evidenced by this test :
    Code:
    // Test
    alert('John\jPaul\p'.match(/^((\w+)|(\\.))+$/));
    
    // Remark : the captured backslash do not appears with the alert
    alert('John\j'); //=>Johnj 
    The match method result is an array of all captured patterns and sub-patterns. Then the patterns seems to be captured many times...
    Last edited by 007Julien; 08-13-2013 at 08:01 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles