+ + " A regular expression to match a string, for example:...">

A regular expression to match a string like: "<any_string> + <any_string> + <any_string>"

A regular expression to match a string, for example:

"<any_string>+<any_string>+<any_string>"?
+3
source share
6 answers

It sounds as simple as:

.*\+.*\+.*

.*matches any_string until the character \+matches the "+" character.

+2
source

here is a non-regular way. In your favorite language, divide by "+", check the length of the array as 3. pseudocode:

s = split(mystring,"+")
if length(s) = 3 then
  .....
end if 

To be more precise, divide by "> + <"

+1
source

S+S+S, S - , < > (, ) :

(<[^>]*>)\+\1\+\1

, :

<a>+<a>+<a>

<a>+<b>+<a>

S < >; +. , :

<a+b>+<a+b>+<a+b>
+1

, ?

[\w\\+]*
0

,

/.*\+.*\+.*/
0

any_string >, , :

<([^>]+)>\+<([^>]+)>\+<([^>]+)>

$1, $2 $3 1, 2 3 . - ([^>]+) ([^>]*), < >.

0

Source: https://habr.com/ru/post/1734368/


All Articles