I want to match this kind of format:
AA sysodufsoufdds AA
Where AA can be arbitary consecutive string with no space in it.
Is there a solution?
I want to match this kind of format:
AA sysodufsoufdds AA
Where AA can be arbitary consecutive string with no space in it.
Is there a solution?
How about this:
^(\w+).*?\1$
This will match any char sequence followed by anything followed by same char seq at the front. So it'll match:
AA sysodufsoufdds AA BBB sysodufsoufdds BBB ABC sysodufsoufdds ABC
This matches a chunk of characters followed by a space followed by anything followed a space followed by the first chunk of characters...
([A-Z0-9]+) .* \1
There are a number of different ways of matching these bits. The key thing is the use of \1
, which is a backrefrence to the first defined pattern. If you had two patterns you could use \2
to refer to the second one. For instance this ...
([A-Z0-9]+) (.*) \1 \2
... would match this string
AA sysodufsoufdds AA sysodufsoufdds