-1

What regular expression matches the below

  • a pattern that's composed of two letters and numbers
  • any comma-space repetitions of said pattern

Assume the below cells, their contents and the times the pattern is repeated

Cell Content Repetitions
A1 CC148 0
A2 CC249, CC193 1
A3 CC345, CC856, CC749 2

For simplicity, I will refer to the regular expression I need as myRegEx

Content Formula Expected Output
CC148 REGEXMATCH(A1, myRegEx) TRUE
CC249, CC193 REGEXMATCH(A2, myRegEx) TRUE
CC345, CC856, CC749 REGEXMATCH(A3, myRegEx) TRUE

The below expressions for each respective cell would return true, but the problem is that I'm after one expression that gets the job done, independently of the number of repetitions.

  • CC\d+
  • CC\d+, CC\d+
  • CC\d+, CC\d+, CC\d+

The below expression didn't bring the desired outcome

  • (CC\d+)|.
player0
  • 124,011
  • 12
  • 67
  • 124
Miltos
  • 23
  • 5
  • Make sure to add input and expected output as **text table** (NOT as IMAGE) to the question. [Click here](https://webapps.stackexchange.com/a/161855/) to create a table easily. Adding such tables greatly increases your chances of getting a elegant answer, as **it is easier to copy/paste**. If you share spreadsheets, your question maybe closed, as questions here must be [self contained](https://meta.stackoverflow.com/a/260455). Your table should be a [mre].[Your email address can also be accessed by the public](https://meta.stackoverflow.com/questions/394304/), if you share Google files. – TheMaster Oct 17 '22 at 15:43
  • `CC\d+` returns `TRUE` for all `A1:A3`. It doesn't need to match from start to end. It will return `TRUE` as long as there's one match anywhere in the string. – TheMaster Oct 18 '22 at 14:08

1 Answers1

-1

try:

=INDEX(REGEXMATCH(" "&A1:A10&",", REPT(" CC\d+,", 
 LEN(REGEXREPLACE(A1:A10, "[^,]", ))+1)))

enter image description here

player0
  • 124,011
  • 12
  • 67
  • 124