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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login