“Python re.split ()” Kode Jawaban

Kompilasi Python Re

import re
#	Compile a regular expression pattern into a regular expression object, which can be used for matching using its match(), search() and other methods, described below.

prog = re.compile(pattern)
result = prog.match(string)

#	is equivalent to

result = re.match(pattern, string)
Blushing Barracuda

Re Python3

import re
>>> m = re.search('(?<=abc)def', 'abcdef')
>>> m.group(0)
'def'
Proud Penguin

Python re.split ()

import re

string = 'Twelve:12 Eighty nine:89.'
pattern = '\d+'

result = re.split(pattern, string) 
print(result)

# Output: ['Twelve:', ' Eighty nine:', '.']
SAMER SAEID

Jawaban yang mirip dengan “Python re.split ()”

Pertanyaan yang mirip dengan “Python re.split ()”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya