Regex Replace Online Tool

Regular Expression

Flags(Part 1)

Flags(Part 2)


Replace To


About Regex Replace Online Tool:

This online Regex Replace tool helps you to replace string using regular expression (Javascript RegExp).

cartoon text editor

Most Common Used Regular Expression:

Email Address: ^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$

Internet URL: [a-zA-z]+://[^\s]*

Chinese Character: [\u4e00-\u9fa5]

Password (starting with a letter, length between 6 and 18, can only contain letters, numbers and underscores): ^[a-zA-Z]\w{5,17}$

Does Regex Replace Online Tool log my data?

Absolutely NOT, this Regex Replacer doing all the formatting work on the client side, all logic are implemented by Javascript. There are 2 major advantages: 1.Your data never transmitted in the Open Internet, so you know it's secure; 2.It's much faster than doing all the work in the server side, because there is no Internet Delay.

More information:

Javascript RegExp CheatSheet: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp

Python re Library: https://docs.python.org/3/library/re.html

Wikipedia (Regular Expression): https://en.wikipedia.org/wiki/Regular_expression

Replace regular expression matches in a string using Javascript:

  1. var regex_replacer = /test/gi;
  2. var test_string = "This is a Test string.";
  3. var replace_to_str = "Result";
  4. var result = test_string.replace(regex_replacer,replace_to_str,test_string);
  5. console.log(result)
  6.  
  7. -------------------
  8. > "this is a Result string."

Replace regular expression matches in a string using Python:

  1. import re
  2.  
  3. regex_replacer = re.compile("test", re.IGNORECASE)
  4. test_string = "This is a Test string."
  5. replace_to = "result"
  6. result = regex_replacer.sub(replace_to, test_string)
  7. print(result)