Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify and Remove any type of Bullet in the Text

I am copyig some data from the MS Word. That text may contain or May not contain Bullets in the copied text. But i need a Regular expression in javascript to remove any type of Bullets from the copied text.
for example if i copy the text which is having bullets it is coming like this when i paste it.
Here are some examples

 1.   Jnflkvkbfjvb
 2.   Kjnfbhvjbv
 3.   ;kbvrjvbrjvb 

 •    Jnflkvkbfjvb  
 •    Kjnfbhvjbv  
 •    ;kbvrjvbrjvb  

 a)   Jnflkvkbfjvb
 b)   Kjnfbhvjbv
 c)   ;kbvrjvbrjvb 

 A.   Jnflkvkbfjvb
 B.   Kjnfbhvjbv
 C.   ;kbvrjvbrjvb 

  I.      Jnflkvkbfjvb
 II.      Kjnfbhvjbv
III.      ;kbvrjvbrjvb 

But My requirement is to display without any of these bullets.It has to display

       Jnflkvkbfjvb
       Kjnfbhvjbv
       ;kbvrjvbrjvb

My code is

      var  x=" •    Jnflkvkbfjvb•    Kjnfbhvjbv•    ;kbvrjvbrjvb 1.     Jnflkvkbfjvb2.    Kjnfbhvjbv3.    ;kbvrjvbrjvb ";
      x= x.replace(/[•\t.+]/g, ''); 
      x= x.replace(/[[1-9][.]\t.+]/g, '');
      alert(x);

Please someone help me.
You can use this to edit the code
http://jsfiddle.net/V2aSg/

like image 382
Reddy Avatar asked Jun 25 '11 16:06

Reddy


1 Answers

Try this

/^\s*(?:[\dA-Z]+\.|[a-z]\)|•)\s+/gm

See it here at Regexr

This checks

^ The start of the row (with the modifier m)

\s* any amount of whitespace

[\dA-Z]+\. At least one (+) digit or A-Z followed by a dot

or

[a-z]\) a-z followed by a )

or

\s+ At least one whitespace at last

like image 193
stema Avatar answered Sep 28 '22 04:09

stema