Regular expression

July 3, 2008

Here is the most frequently used special characters in regular expression of Java script. In a simple and concise way. [Background support : AMIT R.]

*   - 0/n chars >> /raj*/ -> ra, raj,rajj,rajesh, krajesh too [talking about j]
+   - 1/n chars >> /raj=/ -> raj,rajesh, krajesh too but not ra [talking about j]
?   - 0/1 char  >> /raj?/ -> ra, raj, rajj [talking about j]
.   - any SINGLE char expecting at its postion except \n.  [no previous no after]
    /.n/ >> in,on,an but not nan
|  - or >> /java|ruby/  -> java or ruby (dont think a or r) , matches also jruby or rjava
[abc] - matches ANY ONE , same can be written as [a-c]
^   - begin with /^ruby/ -> ruby, ruby programmer but not jruby
$   - end with /ruby$/ -> End with y >> ruby, jruby, kruby but not rubyk
[^a-z]  - Any single match other than a-z
\d   /[0-9]/  i.e. any single digit
\D   /^[0-9]/ i.e. any single char other than 0 to
\w  - Any alphanumeric char other than underscore  [A-Za-Z0-9]

Entry Filed under: coding. Tags: , , .

Leave a Comment

hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Categories

posts[:recent]

episodes[:recycled]

@@name = PRAYAS

Step down at my blog with your ideas,comments,suggestions on Ruby,RoR,Ajax or Web2.0.You may reach me at
infostall@gmail.com

find_by_tags

Links

visitors[:since_Mar'08]

free web counter

Spam Blocked

Feeds

Meta

RSS Prayas here