+ 3
Find something after a key words
I want to find something after a key word or sentence example: here is my index number 123456 I want to return 123456
5 Respostas
+ 3
So you want to find 123456 inside of other text? Sounds like a regular expression job.
Can you provide existing code or sample input, what keyword is being searched for and what output you want if any?
+ 3
I don’t have a regex solution, but python find might be more appropriate, depending on the context.
s = "I want to find index number123456"
s2 = "index number"
i=s.find(s2)+len(s2)
print ("Location of end of index number:",i)
print (s[i:])
https://code.sololearn.com/cRSN8vQB1zlk/?ref=app
EDIT: Autocorrect had made “regex” into “reflex”
+ 1
I mean that the regex may be for example 'index number'
so the result should be what come after 'index number' which is 123456
😊
+ 1
something like this: r' here is my index number (\d{,6})' and then using match.group(0)
0
Here a code for this question:https://code.sololearn.com/cWO3ZGuehCwY/?ref=app