"Shortest Match" in Regex Tester Does Not Return the Shortest Match

Cyrix

Client
Регистрация
16.12.2011
Сообщения
382
Благодарностей
10
Баллы
18
"Shortest Match" in Regex Tester Does Not Return the Shortest Match

There are often shorter match within the returned text.
 

nicanil

Client
Регистрация
06.03.2016
Сообщения
2 242
Благодарностей
1 804
Баллы
113
  • Спасибо
Реакции: Cyrix

Cyrix

Client
Регистрация
16.12.2011
Сообщения
382
Благодарностей
10
Баллы
18
For example, for
<span class=""><span class="">ABC USD
I want to find the shortest match between ">" and "USD", the correct match should be ABC , but Regex Tester wrongly generated a Regex which returns
<span class="">ABC


84750
 
Последнее редактирование:

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 208
Благодарностей
5 839
Баллы
113
For example, for
<span class=""><span class="">ABC USD
I want to find the shortest match between ">" and "USD", the correct match should be ABC , but Regex Tester wrongly generated a Regex which returns
<span class="">ABC


Посмотреть вложение 84750
Shortest match works from what searched text begin with, not from what goes before searched text
You should specify what searched text begin with
for example - (?<=>)\w.*?(?=USD)
 

Cyrix

Client
Регистрация
16.12.2011
Сообщения
382
Благодарностей
10
Баллы
18
The regex formula you provided was not what Regex Tester generated (which produced a wrong result), even when "begin with" was used.

84993
 
Последнее редактирование:

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)