admin管理员组文章数量:1289891
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 ing 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
/
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 ing 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/V2aSg/
- I Have been trying it.. But as of now it is removing only round bullets. – Reddy Commented Jun 25, 2011 at 16:32
- 1 what code have you tried? Could you add it as well? – Dogbert Commented Jun 25, 2011 at 16:33
- Is this you want. – Asad Rasheed Commented Jun 25, 2011 at 16:53
- @Asad Rasheed yes, But please modify your code to make it also work by identifying automatically.Any type of bullet... – Reddy Commented Jun 25, 2011 at 17:03
2 Answers
Reset to default 10Try 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
If we need it for multiple auto-numbered list like
Content
1.1. Content and so on 1.1.1...
Then this regex would (.*?)\d\.\s+|[a-z]\)\s+|•\s+|o\s+|[A-Z]\.\s+|[IVX]+\.\s+|[ivx]+\.\s+
Also, in my case i did not need the empty lines to be replaced/highlighted
Regex Demo
本文标签: javascriptHow to identify and Remove any type of Bullet in the TextStack Overflow
版权声明:本文标题:javascript - How to identify and Remove any type of Bullet in the Text - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741424315a2377987.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论