Regular expression between varying number of characters
You don't need to use lookbehind at all for this, regex like this works:
(?:\d+\.)+(.*)(?:\.\d+)+
https://regex101.com/r/pP6lX7/1
Or if you want to match a line inside some other text
(?:\d+\.)+([^\s]*)(?:\.\d+)+
source to share
You cannot use quantifiers *
or +
or ?
inside lookbehind assertions in perl, java, python regexes (they will not support variable lookbehind lengths). But you can use these characters inside lookbehind in C # family.
If you are using php or perl you can use \K
\.\d*\.\K(.*)(?=\.)
Another hack in all languages - just print all captured characters.
\.\d*\.(.*)\.
An example for the greedy one:
>>> s = "09.043443.EXAMPLETEXT.14"
>>> re.search(r'\.\d*\.(.*)\.', s).group(1)
'EXAMPLETEXT'
An example for non-greedy matching:
>>> re.search(r'\.\d*\.(.*?)\.', s).group(1)
'EXAMPLETEXT'
Use negative char class.
>>> re.search(r'\.\d*\.([^.]*)\.', s).group(1)
'EXAMPLETEXT'
source to share