Wize
Member since Mar 21, 2010
- Profile: /members/5696-wize.htm
- Comments: 4
Recent Blog Comments By Wize
-
Ask Ben: Javascript String Replace Method
Posted on Jun 26, 2010 at 3:52 PM
@John, Try this: var line = "a text includes this in it"; var srchtxt = "in"; var re = new RegExp("\\b"+srchtxt+"\\b", "gi"); newLine = line.replace(re,"out"); document.write(newLine); //output: a text includes this out it... read more »
-
Ask Ben: Javascript String Replace Method
Posted on Mar 26, 2010 at 1:22 AM
This would be a simpler test. Change: abc Abc "abc" ABC to: def Def "abc" DEF Change "abc" to "def", preserve case, but don't change anything in double quotes. What would be the expression to do that? Thanks.... read more »
-
Ask Ben: Javascript String Replace Method
Posted on Mar 25, 2010 at 12:39 AM
I want to change all occurrences of "we" to "they" in the sentence below, but I do not want to change anything within double or single quotes. I also want to keep the case that is used. I believe I need to use look ahead, but I haven't used look ahead that much so I'm not sure how to do it. I'm also... read more »
-
Ask Ben: Javascript String Replace Method
Posted on Mar 21, 2010 at 3:49 PM
I'm confused a bit by what you are asking, but if had this sentence: The color, red, is in the style statement; style: red;. and wanted to remove all or change all of the commas, colons, and semi-colons, my expression would be: [,:;] The result would look like this: The color red is in the styl... read more »