Using the code [A-Z]+[.] will select All-Caps words ending with a period. I was wondering how I would make this include an all-caps word behind it as well.
bold means it is the selected text
current: ASD ASD.
goal: ASD ASD.
Using the code [A-Z]+[.] will select All-Caps words ending with a period. I was wondering how I would make this include an all-caps word behind it as well.
bold means it is the selected text
current: ASD ASD.
goal: ASD ASD.
 
    
     
    
     
    
    If you want to match either one or two words but no more you can make the second word optional with the ? modifier:
(?:[A-Z]+\s+)?[A-Z]+\.
Or if you want to match as many words as there are before a period, you can use the * modifier instead:
(?:[A-Z]+\s+)*[A-Z]+\.
To obtain the index of the start of a match in JavsScript, you can do the following:
var regex = /(?:[A-Z]+\s+)?[A-Z]+\./;
var match = regex.exec('ASD ASD.');
console.log('The index of the first match is ' + match.index)
