I gave it a college try, but I’m stumped. I’m trying to find consecutive slashes within a string. The rest of the regex works great, but the last part I can’t quite get.
Here’s what I have:
val.match( /^[\/]|[~"#%&*:<>?\\{|}]|[\/|.]$/ )
and finding this thread, I decided to update my code to no avail:
RegEx to find two or more consecutive chars
val.match( /^[\/]|[\/]{2,}|[~"#%&*:<>?\\{|}]|[\/|.]$/ )
What do I need to get this thing going?
So, I need this regex to look for many characters. That would explain the first code sample that I provided:
val.match( /^[\/]|[~"#%&*:<>?\\{|}]|[\/|.]$/ )
What I need it to also do, is look in the string for a double whack. Yes, I’m well aware of indexOf and other string manipulation techniques, but I labeled it regex because it needs to be. Let me know if you need more info…
Here’s the answer.
Not sure why the other version doesn’t work, but maybe someone could shed some light onto the matter.
Tests:
Not sure why the code below wasn’t working, but moved the double whack test and it works now: