0

I have a string like this:

<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>

and I want a Regex that will match whenever there's a situation like this:

<https://example.com/code/INSTRUMENTS/AGD<1>
<https://example.com/code/INSTRUMENTS/AGD>1>

to detect such invalidly serialized IRIs (similar to URIs/URLs).

I've looked at existing answers on SO, but none of them seem to work when the inner character is the same as one of the outer characters.

4

1 回答 1

0

假设<总是必须用 a 关闭>并且它们不能“嵌套”:

(<[^>]*<|>[^<]*>)

如果它只是关于布尔检查/验证,这将检测到它们。

如果您还想捕获完整的字符串

(<[^>]*<[^<]*>|<[^>]*>[^<]*>)

(希望没有错别字)

于 2021-04-09T11:59:44.677 回答