moving year in a date from the end to the front.
@gerdb42 Hello again, I have another problem. in a large document i have some lines like this: “-4 497” and like this: “17 787” i want to remove the space? do you know how?
@guy038 Im sorry but i didnt get that to work :(
Did you make sure Search Mode was set to Regular expression?
Maybe show what you did here.
I have a large document that look like this:
“120000” “various” “646958” “20220323” “12” “firstname lastname” “-4 497” “20220407” “646958”
And i want to remove the space in: “-4 497”
@Vegard-Johansen Are the double quotes part of your input? Or did you put them in as a clarification of your question?
In general, it is clearest and easiest when you cut and paste the relevant part of your actual input into a codeblock (triggered by </>).
Its part of the input :)
Find: "(-?\d+)\x20(\d+)" Replace: "\1\2"
@Paul-Wormer did not work :( maybe i do something wrong :(
May be I should have given more details on my regex S/R !
Start N++ and open your document
Open the Replace dialog (
Ctrl + H)
Uncheck all box options
(?<=\d)\x20+(?=\d)in the Find what : zone
Verify that the Replace with : zone is
Regular expressionsearch mode
Click on the
=> All the
Spacecharacters, which exist within numbers, should have disappeared !
- Save the changes
@Vegard-Johansen Did you include the double quotes in both the Find expression and the Replace expression? Did you have exactly one space between the digits? Did you check the regex mode box?
My regex is a sort of brute force solution, I capture quotes and digits before and after a single space and copy them without a space in between them. @guy038 has a more sophisticated solution. He matches one (or more) space(s) that are surrounded by one digit on the left and one digit on the right and replaces the matching space(s) by an empty string.
However, both methods work. I have tried them both.
Your Replace dialog looked right, so I went to your original post and (using my moderator powers) looked at the text you typed rather than what the forum rendered. When I copied from there and pasted into Notepad++, I saw
Please notice that the character between the
497is not a space; it is the special character
NBSP(Non-breaking space). Because you said “i want to remove the space”, and did not accurately tell us what character was between there, we could not derive a regex that works. The
\x20in the regular expression only applies to the normal ASCII space character, not to a tab or to a NBSP or to any other space-like character.
If your Notepad++ is not showing the
NBSPsymbol, then make sure you are on a relatively-recent Notepad++ version (v8.5 or newer), and make sure that View > Show Symbol > Show Non-printing Characters is turned on (has a checkmark next to it):
But back to your question:
Since we now know it’s a non-breaking space, we can change @guy038’s regular expression to
(?<=\d)\xA0+(?=\d), and that will match just if there’s a non-breaking space between those characters. If there might be any horizontal space (real space, tab, nbsp, or others), then use
(?<=\d)\h+(?=\d)instead, to make it match on any horizontal space.
This shows the importance of knowing (and sharing) what the actual characters are.
@PeterJones Good catch! I started to suspect something like that. Would we have seen it if he had cut and pasted his input into a code block?
Would we have seen it if he had cut and pasted his input into a code block?
Nope, the forum turns NBSP into a normal space, even in a code block. (I tried before posting my reply). Code boxes are better, but they don’t give 100% of what’s being pasted. (This forum software was designed for generic use, and isn’t specialized in being able to post things that tend more toward the “binary” nature rather than “normal text”)
For @Vegard-Johansen and others who don’t know, the “code boxes” are generated by:
- Paste your text in the forum
- select that text
- Click the
</>button on the forum’s post-editing toolbar :
This would take your text, and the edit panel would have shown
``` "120000" "various" "646958" "20220323" "12" "firstname lastname" "-4 497" "20220407" "646958" ```
and it would render as
"120000" "various" "646958" "20220323" "12" "firstname lastname" "-4 497" "20220407" "646958"
That would have been better than what you posted, because it at least showed the real quote marks rather than the “smart quotes” that we see in your post. But unfortunately, a special character like the NBSP doesn’t come through even then.
Good intuition, @peterjones, indeed !
I suppose that the
Non Breaking Spacecharacters are intentionally used between parts of a number. So, when the text of this document is wrapped, any number will be moved entirely to the next line and not separated in two parts ( one part at the end of a line and the remaining of the number on the next line )
Maybe answers in the future should use
[\x20\xA0]to match spaces. :-(
\his often appropriate (but it isn’t as exacting).
Thank so much, this community is so nice. it worked with this one: (?<=\d)\xA0+(?=\d) in the document. hopefully it will work tonight when the system import file. i will let you know 100% tomorrow :) Again thank you so much for all help!