-2

I need to locate all strings in a large text document which includes 3 letters and 3 numbers such as: FPV003

But there are hundreds of different strings of such type in-between regular text,

I've tried Regex, but cant get it to work,

How do I locate these 6 charactered strings consisting of 3 random numbers and 3 random letters.

2 Answers2

0

A regex should be fine here :

var patt = /[A-Z]{3}[0-9]{3}/g;
var str = "test test AZE123 test test ZER456";

console.log(str.replace(patt, 'it works'));
Zenoo
  • 12,670
  • 4
  • 45
  • 69
0

Thank you so much :) So all the strings I need to find comes in order of LETTERLETTERLETTERNUMBERNUMBERNUMBER aaa111 So I think it will find everything with this code;

var content = document.getElementById('indhold').innerText;
var UID = content.match(/[a-zA-Z]{3}[0-9]{3}/g)