![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
If I have a snippet of javascript code like this: var str = "This is a snippet; str.replace(/ */gi,' '); what should the call to replace do? |
|
My actual tests show that it inserts spaces between each letter... |
|
but this doesn't make sense to me. From the regex, it looks like it should be replacing any occurrence of a space followed by any character with a space, |
#3
| |||
| |||
|
|
If I have a snippet of javascript code like this: var str = "This is a snippet; str.replace(/ */gi,' '); what should the call to replace do? My actual tests show that it inserts spaces between each letter... but this doesn't make sense to me. From the regex, it looks like it should be replacing any occurrence of a space followed by any character with a space, meaning that we should have something like 'This s nippet'. Please help me clarify this. |
#4
| |||
| |||
|
|
If I have a snippet of javascript code like this: var str = "This is a snippet; ^[1] str.replace(/ */gi,' '); ^^[2] what should the call to replace do? |
|
My actual tests show that it inserts spaces between each letter... |
![]() |
| Thread Tools | |
| Display Modes | |
| |