Before special character select the text in javascript by regular expression


hi,

 

can u write regular expression so  can select text before special charachter (exp : ";").

 

examplese

  text : absolute;   or  -9px; or  100% 100%;

output : absolute or -9px or 100% 100%

 

i write

 

var reg = /^((?:'(?:\\'|.)*?'|(?:\\|.)*?|\([^\)]*?\)|[^};])+)\s*/;

var m = reg.exec ("absolute;");

 

but not giving me correct output.


 

regards

ashish yadav.



 


we need more facts to give you the right answer.

 


if want to replace the semicolons in text frame:


var adoc = app.activedocument; var atframe = adoc.textframes; contentstring = atframe[0].contents; contentstring = contentstring.replace (/;/g, ''); atframe[0].contents = contentstring; 

 

this gives the right output for your sample text.

otherwise give better example please.



More discussions in Illustrator Scripting


adobe

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account