How do I concatenate a string variable to a regular expression. e.g var re = /^-?(\d/ and str=","
Apr 5th, 2008 20:39
ha mo, Colin Fraser, Sam maran,
I am not sure exactly what it is that you are getting at but if I am
reading you right try :
document.write("The end result is "+re+" "+str)
although I would probably be more likely to write this one as
document.write("The end result is "+re+", ")
depending on what is to folow the statement.
As a general coding tip, when I am coding something for the first time,
I write the resultant string out how I want it to appear, then just
replace what is required with the above formatting. Use as many
variables as you need to. Also if the sentence is going to appear more
than once, what can you place into constant strings? I might try
something like :
var const="The end result is "
var str=", "
again, depending on what is to follow.
I hope this has been helpful.