string_grab
1.0.0
แยกส่วนย่อยหนึ่งหรือหลายตัวระหว่างสองสตริงเริ่มต้นและปลาย
ฟังก์ชั่น: grab, grab_all, grab_until, grab_after, inject, inject_until, inject_after
from string_grab import grab
text = '''Gender: female
Race: White
Birthday: 3/23/1973
Mobile: 715-523-1076
Mobile: 715-563-3967
Street: 4674 Lynn Avenue
City, State, Zip: Eau Claire, Wisconsin(WI), 54701'''
birthday = grab ( text , start = 'Birthday: ' , end = ' n ' )
print ( birthday )
>> '3/23/1973'ส่งคืนสายแรกระหว่างสองสาย 'เริ่มต้น' และ 'สิ้นสุด'
ตัวแปร: grab_all, grab_until, grab_after
grab ( 'John likes apples.' ,
start = 'John likes ' ,
end = '.' )
>> 'apples' แทรกสายย่อยแทนที่ทุกอย่างระหว่างสอง 'เริ่มต้น' และ 'ปลาย' สตริง
ตัวแปร: inject_until, inject_after
inject ( 'John likes apples.' ,
'oranges' ,
start = 'John likes ' ,
end = '.' )
>> 'John likes oranges.'ให้ผลผลิตย่อยทั้งหมดระหว่างสองสาย 'เริ่มต้น' และ 'สิ้นสุด'
ดู Grab.
results = grab_all ( 'John likes apples. John likes oranges.' ,
start = 'likes ' ,
end = '.' )
list ( results )
>> [ 'apples' , 'oranges' ]ส่งคืนทุกอย่างก่อนสตริง 'End'
ดู Grab.
grab_until ( 'John likes apples.' ,
end = ' likes' )
>> 'John' ส่งคืนทุกอย่างหลังจากสตริง 'Start'
ดู Grab.
grab_after ( 'John likes apples.' ,
start = 'likes ' )
>> 'apples.'แทรกสายย่อยแทนที่ทุกอย่างก่อนสตริง 'สิ้นสุด'
ดูการฉีด
inject_until ( 'John likes apples.' ,
'Sarah' ,
end = ' likes' )
>> 'Sarah likes apples.' แทรกสตริงย่อยแทนที่ทุกอย่างหลังจากสตริง 'เริ่ม'
ดูการฉีด
inject_after ( 'Sarah likes apples.' ,
'oranges.' ,
start = 'likes ' )
>> 'Sarah likes oranges.'