How do I create regex to split string up exactly into 3 parts? (PHP)

Basically I have a bunch of strings in a database and I need to split them into 3 parts. First part should be the very first word, nothing else, so I can use explode for that. The second and third parts are tricky, as the string and word length is not consistent, for example:

  • Michelin Alpin 3 185/70 R14 GRNX --> [Michelin] [Alpin 3] [185/70 R14 GRNX]
  • Continental VancoWinter 2 225/75 R16C C M+S --> [Continental] [VancoWinter 2] [225/75 R16C C M+S]
  • Kleber VIAXER 175/70 R13 82T --> [Kleber] [VIAXER] [175/70 R13 82T]

I tried quite a few regex patterns to get these 3 parts back, but no luck so far. I would really appreciate any ideas!



Read more here: https://stackoverflow.com/questions/64403564/how-do-i-create-regex-to-split-string-up-exactly-into-3-parts-php

Content Attribution

This content was originally published by Balázs Kozma at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: