PDA

View Full Version : RegExp = new (headache!)


ez4ne12c
03-18-2003, 11:30 AM
[thump] [thump] [thump] said my head to a wall...

Hi there,
i have read some documentation but i cant get RegExp to work
all i wanna do is replace all \ in my string with \\ cause they are getting striped off
please help meeeeeeeeeeee
ez:confused: :( :mad: :eek:

timur
03-18-2003, 11:33 AM
try to use helmet (for the wall)

and this

str.replace(/\\/ig, '\\');

for your js script

ez4ne12c
03-18-2003, 12:05 PM
my head still hurts
heres what i got..\

thumb_url=""+readers_files.item();
thumb_url.replace(/\\/ig,'\\\\');

book_link = "\"<IMG src='"+thumb_url+"' alt='"+book_name+"' onClick='pager()'></img>\"";

alert (book_link);
//this still shows single backslashes which are stipped off by eval

eval('book'+i+'.innerHTML='+book_link+';');

really, its that bad!
ez :mad: :confused: :mad:

ez4ne12c
03-18-2003, 12:13 PM
please ignore last message
it finally works ... me bit slow today/night...
MANY thanks to you timur <---- xoxoxoxox
:cool: :D :cool: :D :)
ez

liorean
03-18-2003, 02:27 PM
Try this:
str=str.replace(/\\/g,'$&amp;$&amp;');
or this:
str=str.replace(/\\/g,'\\\\');
They both do the same thing.


I wouldn't use eval for that, by the way. Try this:
book[i].innerHTML=book_link;

ez4ne12c
03-19-2003, 12:28 AM
yeah i get what you mean, an array would make more sense..
Thanks liorean & timur
:D ez