" and less than "<" in a string I need a regex that replaces a greater and less character than a ...">

A regular expression that detects more than ">" and less than "<" in a string

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

+3


source share


3 answers


You can use regEx |

like

var regEx = /<|>/g;
var testString = "<test>"
alert(testString.replace(regEx,"*"))

      



Fiddle

+1


source


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);

0


source


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

-1


source







All Articles