M
M
Mr.2020-05-30 12:19:40
Regular Expressions
Mr., 2020-05-30 12:19:40

How to fix the regular expression? Or how do you know where it's wrong?

1} Site link
https://readmanga.me/stat_avantiuristom____kak_pro...
Code =REGEXEXTRACT( INDEX(IMPORTHTML(B7;"table";0);2;1); ".*?\-.*?(\d+ )" )
ND Error
Should output Number 15. Located at the bottom at the beginning of the table.

2} Site link
https://mintmanga.live/since_i_received_a_cheat_an...
Code =REGEXEXTRACT(INDEX(IMPORTHTML(B31;"table";0);2;1);".*?\d+\s*\-. *?(\d+)")
ND error.
Should produce Word Extra. It is located at the bottom of the table.
Spreadsheet https://docs.google.com/spreadsheets/d/13lzkFlnGGB...
Location of errors 1{b8} 2{b32}
I will be glad if you tell me what characters I need.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SagePtr, 2020-05-30
@SagePtr

https://regex101.com/ convenient and highlight, and allow you to compare the regular expression with your text samples

D
dodo512, 2020-05-30
@dodo512

There, in the text, there are newline characters "\n", and in the construction .*, the dot matches any characters except "\n". In order for the dot to match the newline characters, just add (?s)
Instead of ".*?\-.*?(\d+)" put "(?s).*?\-.*?(\d+)" or " (?s)-.*?(\d+)"
(\d+) only matches numbers, so the word Extra won't match the pattern ".*?\d+\s*\-.*?(\d+)".
You can try this pattern "\d+\s*(?:-\s*)?(.+)"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question