Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var str = "///a/ab*/*/bc:dD:123a///'Ad/,.?/!//";
- //if I use js replace with regex rule twice I get needed result
- "///a/ab*/*/bc:dD:123a///'Ad,.?/!//"
- .replace(/[^0-9a-zA-Z()+-.,‘?/:]/g, "")
- .replace(/[^/+|/+$|/{2,}]/g, "");
- //result
- "a/abbc:dD:123aAd/,.?"
- **Is it possible to combine these rules into one regex rule?!**
- //tried to combine these rules by '|' but get failure result
- "///a/ab*/*/bc:dD:123a///'Ad/,.?/!//"
- .replace(/([^0-9a-zA-Z()+-.,‘?/:])|^/+|/+$|/{2,}/g, "")
- //result
- "a/ab//bc:dD:123aAd/,.?/"
- 'a/ab*/*/bc'
- 'a/ab//bc'
Add Comment
Please, Sign In to add comment