V
V
Viktor2015-11-11 08:33:21
Regular Expressions
Viktor, 2015-11-11 08:33:21

Regular how to set group value?

There is a regular expression of the form
/^(?P<param>(?(?=var)|.*))$/u
and the string
var/test
or
vas/test
It is necessary that if the string starts with "vas", then in the "param" group, write not the entire string "vas/test", but only the end of the string equal to "test"
Example https: //regex101.com/r/kQ1nG0/1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
heartdevil, 2015-11-11
@heartdevil

Hello.
You don't need a regex for this. It will only get harder for her.
If you write in php, then look for search functions directly either var/test or vas/test.
But if you really need it with a regular season, then here:
I suffered a little.
See here
The pcre(php) engine is used. Need modifier J

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question