" and less than "<" in a string I need a regex that replaces a greater and less character than a ...">
I need a regex that replaces a greater and less character than a string
I've already tried
var regEx = "s/</</g;s/>/>/g" var testString = "<test>" alert(testString.replace(regEx,"*"))
My first time to use it please walk through on me :) Thanks
You can use regEx | like
|
var regEx = /<|>/g; var testString = "<test>" alert(testString.replace(regEx,"*"))
Fiddle
For a larger and smaller symbol.
var string = '<><>'; string = string.replace(/[\<\>]/g,'*'); alert(string);
For special characters
var string = '<><>'; string = string.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g,'_'); alert(string);
Insert regex in code before class
using System.Text.RegularExpressions;
below is the code to replace string with regex
string input = "Dot > Not Perls"; // Use Regex.Replace to replace the pattern in the input. string output = Regex.Replace(input, "some string", ">");
source: http://www.dotnetperls.com/regex-replace