I am new to python and i am trying to extract particular word from the content below starting with letter B and its following 10 characters. Example as shown below.
"FnSku/X-label from the item:na
Incorrect value: BXXXXXXXXA
Correct (if available):na
Condition of the part(Used/New?): new
Purchase order:na"
I am looking to extract the word BXXXXXXXXA. I tried to split the content and find the word that startswith 'B' however since word does not start with B i am unable to extract the same.
Note: the content is not always the same but the count of letter starting with B is always 10.
Please help !
It's possible with regular expression:
import re
Words_starting_by_B= re.findall("B\w{9}", text)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.