0

Assuming I have the following two strings:

START dsad COMMAND5 name

 

START hfhsaklk342cxz COMMAND8 name

 

I want to be able to analyze and find the common structure between the strings:

START ### COMMAND### name

(### marks changing data).

(They all start with "START ", followed by something, then " COMMAND", then something, then " name")

 

Any ideas?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Avenger
  • 441
  • 1
  • 3
  • 11
  • 1
    Instead of looking for the common parts, you may be better off looking for the difference: http://stackoverflow.com/questions/321294/highlight-the-difference-between-two-strings-in-php – Joeri Sebrechts Nov 08 '12 at 12:06
  • It seem you already know the common parts. Can't you use a regular expression to parse those strings? Something like `'START\s([a-z0-9]*)\sCOMMAND[0-9]\sname'` – GolezTrol Nov 08 '12 at 12:09
  • That's the problem - I don't know the common parts, this was just an example. @JoeriSebrechts - Thanks, it didn't cross my mind to use Diff. I'll look into that! – Avenger Nov 08 '12 at 12:12
  • This question is [too broad](http://stackoverflow.com/help/on-topic). There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. – Jørgen R Dec 26 '15 at 21:39
  • The problem is, how do you know what different is for sure? This task is not a well specified. It is a clear AI problem. – Willem Van Onsem Dec 26 '15 at 21:39

0 Answers0