Python: extracting text from strings using a key phrase -


struggling trying find way this, great.

i have long string – it’s title field. here samples.

air-lap1142n-a-k air-lp142n-a-k used airo 802.11n draft 2.0 singleaccess point air-lp142n-a-9 airo air-ap142n-a-k9 ios ver 15.2 mint lot of (2) air-la112n-a-k9 - dual-band-based 802.11a/g/n genuine airo 112n  ap air-lp114n-a-k9 poe wireless ap air-lp114n-a-9  airy 50 availiable 

i need pull part number out of title , assign variable named ‘partnumber’. part number start characters ‘air-‘.

so example-

title = ‘air-lap1142n-a-k9 w/power cord’ partnumber = yourformula(title) 

print (partnumber) output air-lap1142n-a-k9

i new python , appreciate help. print part number not other text before or after.

def yourfunction(title):     word in title.split():         if word.startswith('air-'):             return word  >>> partnumber = yourfunction(title) >>> print partnumber  air-lap1142n-a-k9 

Comments

Popular posts from this blog

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -