Remove one character before a character
-
Hi, so I have a long list separated by one character, and I need them to be separated by only one space.
So for example, I have this:
Test | Word
And I want this:
Test WordI can’t just replace | with blank because it will leave two spaces instead of one.
Help? -
If the | is always surrounded by two spaces you can replace " | " with " " (remove the speech marks they were just to highlight the use of spaces)
Jon
-
Bear in mind that the replacement string can be empty, which effectively means destroy/delete what i want to find.
In your case however that would leave 2 spaces together. Try this:
Find:\h|\h
Replace:\h
The \h looks for a space (Horizontal spacing. This only matches space, tab and line feed). So we have look for a space followed by the character I want, then another space and replace with only 1 space.Terry
-
If you had Test | Word and replaced the | with a space then you would have three spaces, not two.
If your list uses | as a separator and that sometimes there are one or more spaces before and/or after the | then use regular expression mode.
Search for: \x20*\|\x20*
Replace with: \x20- The first \x20* looks for zero or more leading spaces. I used \x20 rather than a space self as it’s easier to see on the screen.
- \| looks for the |. In regular expression mode a | is special and so use \| to search for a | itself.
- The second \x20* looks for zero or more trailing spaces.
If your data has either one or zero spaces before and after the | and never had two or more spaces before/after the | then you can use
Search for: \x20?\|\x20?
Replace with: \x20