-2

Alright, I am really new into this and might be a stupid question but I have a word "kirtna" that appears in more than 1000 HTML files that are saved in my assets folder. It's in proper HTML file format which was pasted into Mac's TextEdit and saved to HTML. Now I want the alphabet 'a' to be appeared before 'n'. So instead of "kirtna" it should be "kirtan". I know I can do that Java itself using Regex such as below:

String word = "instant";
String replaced = input.replaceAll("(\\w)a", "a$1");

But can I really do this in HTML?

2 Answers2

5

Well, I don't know how do you want to use this in "HTML", which is not a programming language...

One way to achieve this would be to use a text editor like Notepad++, which is able to do text replacement in a given folder (with regex if you need).

Raphaël Althaus
  • 59,727
  • 6
  • 96
  • 122
0

Is it possible to use Regex in HTML?

The answer is: not really.

HTML5 Input has a "pattern" Attribute, which could be used for pattern matching / Validation.

For your job, it would be best to use Javascript's String.replace. Here is a fiddle to play with.

document.getElementById("test").addEventListener("blur", function(e){
    var textBox=e.target;
    textBox.value=textBox.value.replace("a","blabla");
});
Thomas Junk
  • 5,588
  • 2
  • 30
  • 43