0

I want to add more space between two numbers. For example:

11267-0-001 156465343224546543654
11267-0-002 457328642874435765477
11267-0-003 764987894666524352345

I want to add more space there, where you can already see one space. I tried it with a regex like.. "11267-\d+-\d+" and wanted to replace it with "11267-\d+-\d+ " but as you can imagine, the numbers after 11267 disappeared and it replaced them with \d+-\d+ like this:

11267-d+-d+      156465343224546543654
11267-d+-d+      457328642874435765477
11267-d+-d+      764987894666524352345

how do I do it? I want notepad to look for a pattern like the one I showed, and then without replacing that pattern, it should just add more space or other letters/digits/characters after that pattern.

help-info.de
  • 6,695
  • 16
  • 39
  • 41
pogos
  • 45
  • 8
  • 2
    Use capture groups `()`. Like `11267-(\d+)-(\d+)` – chris85 Jul 27 '17 at 16:59
  • i read about that, too. bit somehow it didnt work (or i did something wrong). i tried it like this: ([11267-\d+-\d+]) and replaced it with /1 or $1 but somehow im sure, that i used it wrong. – pogos Jul 27 '17 at 17:01
  • You need a capture group per value. Also `[]` makes a character class. – chris85 Jul 27 '17 at 17:02
  • i see.. i will try it. what exactly is a character class? (and by the way.. do you know a website where i can learn stuff like that.. something like a "basic tutorial"?) – pogos Jul 27 '17 at 17:04
  • Try the first regex I posted. A character class is a list of characters you want to allow. http://www.regular-expressions.info/ has a lot of info. regex101.com is a good sandbox – chris85 Jul 27 '17 at 17:05
  • thanks. i tried find: "11267-(\d+)-(\d+)" and replace: "11267-(\d+)-(\d+) " but unfortunately, still replacing it with -d+-d+. do i need to check/uncheck some boxes? like.. ",atch case", "wrap around" and ". match newline" ? – pogos Jul 27 '17 at 17:07
  • Regexs are only used in the `find`, you need to use the replacement values in the `replace`. – chris85 Jul 27 '17 at 19:30

1 Answers1

0

You need to capture your numbers so that you can reference them in the replacement. Try:

Find what:    (11267-\d+-\d+)\s+
Replace with: \1[your_spaces_here]

As for where to learn regular expressions, there's a brief on them in this answer with quite a nice collection of resources at the end.

zwer
  • 24,943
  • 3
  • 48
  • 66
  • that helped me. thank you. can you maybe.. explain what "\s+" is doing? is it like... "dont change the "find value but add something"? and about \1 .. what exactly is it doing? – pogos Jul 27 '17 at 17:11
  • @pogos - The first part `(11267-\d+-\d+)` forms a capturing group (the brackets around it) so that you can later reference it as `\1` (if you have more capturing groups the next one can be referenced as `\2`, the next one as `\3` etc.) `\s+` means select one or more space characters. So what the pattern does is captures the first part and selects the space following it, and then in the replacement you're referencing the first capture and instead of the space you can place as many spaces as you want. – zwer Jul 27 '17 at 17:19