3

To find tags and replace text between tags in Notepad++, I do use the following example:

(?<=<barcode>)(.*)(?=</barcode>)

I was wondering if it is possible to search between certain tags for a text that contains more than 20 characters?

4
  • Why does this code works only up to 20 characters?
    – Hastur
    Commented Jan 21, 2021 at 11:49
  • Maybe figure out where to slap in {21,} somewhere. Commented Jan 21, 2021 at 11:52
  • Could it be some spaces or linebreaks within the string?
    – Toto
    Commented Jan 21, 2021 at 15:06
  • Just replace .* with .{21,} or .{20,} depending if you want strictly >20 or >=20 characters
    – Toto
    Commented Jan 21, 2021 at 15:09

1 Answer 1

2

You can use or adapt the following expression for your needs.

[\S] finds all characters except space (identical to [^\s]) and {21,} requires at least 21 characters of text.

(?<=<barcode>)([\S]{21,})(?=</barcode>)

For text with spaces use:

(?<=<barcode>)(.{21,})(?=</barcode>)

enter image description here

3
  • I knew there was a way to do that! Commented Jan 21, 2021 at 13:49
  • Great! That works... Thank you!
    – Syb
    Commented Jan 21, 2021 at 14:56
  • I am sorry, I could not find the grey/green ✓ Now I did :-)
    – Syb
    Commented Jan 22, 2021 at 18:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .