Skip to content
Advertisement

Seach txt File for a keyword like [word & random number]

I have this code:

JavaScript

I want to search Text.txt for a keyword that contains a random number, that looks like this:

Keyword = [Word & random Number] or [ABC-1] / [ABC-1234]

The “Word” part is always the same but the number is up to 4 decimals (1-9999).

When the keyword is found, i want to highlight it like this:

ABC-1 to #ABC-1# with

JavaScript

Question:

How can i search the file for ABC-1 and not just ABC

Advertisement

Answer

Using regular expressions and backreferences

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement