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> <pre> <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

1st April 37signals 360 2008 aamir aamir new look abdul abhinay access active active record aishwarya AJAX AMC amul and bollywood class facebook ghajini google hosting India instance local mozilla myspace nil NY object objects olympic plugin prayas programming Rails RoR Ruby security talent variables web web2.0 windows yahoo

Blogroll

visitors[:since_Mar'08]

free web counter

Spam Blocked

Feeds

Meta

RSS Prayas here