...

View Full Version : need help for regular expression



raneeshak
08-28-2008, 09:15 AM
Hi all,

I am new to the regular expression. i need to get string in between two '$' signs, like data from $data$. May i get the matched string as an array in case
of more than one match? please help, Thanks in advance

Regards,
Raneesh

barkermn01
08-28-2008, 11:44 AM
<script type="text/javascript">

var test = "This will $pull$ out the $keywords$ raped in $US Currency$ signs signs"
var mySplitResult = test.split("$");

document.write(mySplitResult[1]+'<br />');
document.write(mySplitResult[3]+'<br />');
document.write(mySplitResult[5]+'<br />');
</script>

if you can follow the patten this will seperate the words inbetween $ so mySplitResult[0] = "This will" ect...

Hope this helps

raneeshak
08-28-2008, 12:12 PM
Thanks barkermn01 for the help. but it seems to have some problems when there is \$. Almost it worked for me





<script type="text/javascript">

var test = "This will $pull$ out the $keywords$ raped in $US Currency$ signs signs"
var mySplitResult = test.split("$");

document.write(mySplitResult[1]+'<br />');
document.write(mySplitResult[3]+'<br />');
document.write(mySplitResult[5]+'<br />');
</script>

if you can follow the patten this will seperate the words inbetween $ so mySplitResult[0] = "This will" ect...

Hope this helps

barkermn01
08-28-2008, 12:29 PM
that is because your escaping the $ to fix it when u get \$ use \\$ that way the \ is escaped befor it escapes the $ it sould then work for you



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum