From this string
s = 'stringalading-0.26.0-1'
pattern = r'\d+\.\d+\.\d+\-\d+'
pattern = r'[.\-\d]+'
In : re.findall(pattern, s)
is it possible to to skip the first occurrence of a character in a group, in this case the first occurrence of -?
NO, because when matching, the regex engine processes the string from left to right, and once the matching pattern is found, the matched chunk of text is written to the match buffer. Thus, either write a regex that only matches what you need, or post-process the found result by stripping unwanted characters from the left.
I think you do not need a regex here. You can split the string with
- and pass the maxsplit argument set to
1, then just access the second item:
s = 'stringalading-0.26.0-1' print(s.split("-", 1)) # => '0.26.0-1'
See the Python demo
Also, your first regex works well:
import re s = 'stringalading-0.26.0-1' pat = r'\d+\.\d+\.\d+-\d+' print(re.findall(pat, s)) # => ['0.26.0-1']