K
K
kocherman2012-04-11 18:26:18
PHP
kocherman, 2012-04-11 18:26:18

How to teach a regular expression so that preg_match_all looks for strings where there is no subpattern?

For example, there is a regular expression
"^.*<a.*$"
which searches for all lines with links.
How to make such an expression so that preg_match_all gives out all lines where there are no links?
UPD The problem is that I can't use anything other than a regular expression, the script is obfuscated. You can't implement your own logic.
Miraage , I'm not sure, because I don't see the logic, but it searches line by line in the file. That is, it is quite possible that there he scours the file and checks preg_match for each line.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
TROODON, 2012-04-11
@TROODON

/ Everybody stand back /
i know regular expressions

Regular expressions:
/^(?>(?!(\<a.*href)|\<\/a).)*$/umi
Example:
ideone.com/g5vDT
Example source :
pastebin.com/ZkWguPS2

M
Meliborn, 2012-04-11
@Meliborn

Something tells me that XPath is needed here :)

H
Hint, 2012-04-11
@Hint

In my opinion, only "stripped down options" are possible.
Without letter a: ^[^a]+$
Without parenthesis: ^[^<]+$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question