Hello, I'm a beginner at Python.
For example, in the text below,
"""
16 abc('aaa/bbb/hello').<br>
17 abc('aaa/bbb/@y14').<br>
18 abc('aaa/bbb/@y15').<br>
19 abc('aaa/bbb/@y16').<br>
20 abc('aaa/bbb/@y17').<br>
21 abc('aaa/bbb/@y18').<br>
22 abc('aaa/bbb/@y19').<br>
"""
hello
, @y14
, @y15
, @y16
, @y17
, @y18
, @y19
of each line
Regular expression
p=re.compile(r"\w+[/]+\w+[/]+(\w+)", re.MULTILINE)
m=p.findall(text)
I can only see hello
because I can't recognize @ like this, is there any other way?
s = ' 16 abc(\'aaa/bbb/hello\').<br>'
s = s[18:]
s = s[0:s.index("\'")]
print (s)
->hello
s = ' 17 abc(\'aaa/bbb/@y14\').<br>'
s = s[18:]
s = s[0:s.index("\'")]
print (s)
->@y14
© 2024 OneMinuteCode. All rights reserved.