Regular Expression for matching string like:
"<any_string>+<any_string>+<any_string>"?
Regular Expression for matching string like:
"<any_string>+<any_string>+<any_string>"?
It sounds as simple as:
.*\+.*\+.*
the .* matches any_string until the \+ matches a "+" symbol.
If any_string would not contain the delimiter character >, you can easily do that using:
<([^>]+)>\+<([^>]+)>\+<([^>]+)>
$1, $2 and $3 in the match would contain the 1st, 2nd and the 3rd strings respectively. This regex doesn't allow empty strings - change ([^>]+) to ([^>]*) to allow empty strings between < and >.
here's a non-regex way. In your favourite language, split on "+", check the length of array to be 3. pseudocode:
s = split(mystring,"+")
if length(s) = 3 then
.....
end if
To be more "accurate", split on ">+<"
This matches S+S+S where all three occurrences of S is the same string, which is < and > surrounding any (possibly empty) string:
(<[^>]*>)\+\1\+\1
In other words, this matches:
<a>+<a>+<a>
But it doesn't match
<a>+<b>+<a>
S must be surrounded by < and >; it can contain +. So this matches:
<a+b>+<a+b>+<a+b>