user2575502
user2575502

Reputation: 703

how to exclude some reg pattern

I want to write a regular expression to search out all "http" string and replace it with "https", I use following Reg expression:

\bhttp\b    

but some results are not what I want, for example:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

so how can I exclude this? I want to use notepad++ to do this.

Upvotes: 1

Views: 96

Answers (1)

hmedia1
hmedia1

Reputation: 6200

Ultimately if the data is not structured, and you have to string filter, then you need to assess the whole dataset, and decide if this is to be done as a once-off, or if you need a system to do frequently perform the same type of operation, on similar documents, or very different documents, etc..

If it is only the meta line example you want to exclude:

  • You can try \bhttp[^-]\b

If all relevant instances of http are in a certain format, i.e. href="http:

  • Then you could just be more specific with the context. i.e. \b(?<=href=")http\b

The latter example will match using href=" but not include it in the replace operation

Upvotes: 1

Related Questions