It is now possible to extract specific strings from complex text sentences.
You'll be amazed by the really useful features.
This is the main subject.
It would be nice to extract a specific string, but
I got stuck in the operation from there.
Here is the string.
0 [hour] + 2 [minute] 0 [hour] + 47 [minute] 0 [hour] + 4 [minute] 0 [hour] + 23 [minute] 0 [hour] + 3 [minute]
Suppose we read the above string.
The next goal is to find the total time in minutes.
In this case, the desired value (execution result) is 79.
"" " '.' Represents an arbitrary character string. '/ d' represents any number. Looking for operations that might be helpful from the web, I tried to write a code once, but the execution result is "" " 0 [hour] + 2 [minute] 0 [hour] + 47 [minute] 0 [hour] + 4 [minute] 0 [hour] + 23 [minute] 0 [hour] + 3 [minute] 0 [hour] + 40 [minute] 0 [ h o u r ] + Four 0 [ m i n u t e ] # It was a failure.
Added (actual code I wrote)
I do n’t know what I ’m doing.
# processA is read from the plaintext with the with syntax. for el in processA: re.findall ('/ d [minute]', el) if el: print (el) for q in el: re.findall ('/ d [minute]', q) if q: print (q) "" " I want the X part of X [minute]. An error was also issued by changing 'q' to '/ d' in the code. "" "
Answer # 1
The number is
\ d, not
import re text = "" " 0 [hour] + 2 [minute] 0 [hour] + 47 [minute] 0 [hour] + 4 [minute] 0 [hour] + 23 [minute] 0 [hour] + 3 [minute] "" " result = re.findall (r '\ d + (? = \ [minute])', text) print (result)
Answer # 2
I don't know what I am doing.
I'm sure it doesn't do anything meaningful with regular expressions.
for el in processA: re.findall ('/ d [minute]', el) # Since no return value is used, it is the same as not if el: # True unless it is an empty string print (el) for q in el: re.findall ('/ d [minute]', q) # Since no return value is used, it is the same as not if q: # True unless it is an empty string print (q)
If you rewrite roughly,
for el in processA: # seems to be reading line by line (processA is probably a file object) print (el) # display line by line for q in el: # loop the last line displayed one character at a time print (q) # display one character at a time
- python 3x - i want to extract only strings and numbers from a data frame (object type) that contains a mixture of strings, numbe
- python - i want to automatically extract the desired area
- dart - extract strings in sequence without duplication
- python - i want to add a condition from a list of numbers and calculate the average value
- ruby - i want to extract multiple character strings with the same condition contained in the character string
- python 3x - i want to extract using python3 refindall
- extract specific rows from python csv data
- extract specific line in python
- python - extract unique values from all values in multiple columns
- python 3x - python3 i want to convert hexadecimal numbers to array components
- extract python excel file column
- about extracting python strings
- python - i want to customize the selection of strings with qlineedit
- python - i want to extract the character string excluding the blank characters at the end of the line
- python - i want to output decimal numbers when printing after putting numbers entered as integers in the list
- python - i want to give index numbers to the elements of the file
- how to extract only required rows [python, bitalino]
- mixing vba strings and numbers
- python want to extract specific lines from multiple txt files and output to excel
- python - i can't count the number of numbers except the period, calling up a sequence of text files, adding them, truncating the
- ubuntu - to launch vs code remotely
- python 3x - i want to download pippy
- python - i want to know how to eliminate no module named'flask'
- python - i want to create a shortcut in a specific folder
- python - unicodedecodeerror when installing pip on windows
- i have python and pip installed on windows, but i can't install using pip
- regarding arguments for superclass constructors in python tkinter
- error occurs in getelement method of htmlobject obtained from win32comclient in python37
- windows 10 - visual studio code won't start
- python 3x - unclear code in tkinter (python) written in object-oriented