Replace tabs/spaces NOT at beginning -or- end of the line
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Replace tabs/spaces NOT at beginning -or- end of the line
I have no problem trimming the dead space at the beginning or end of a line; this thread is when random line-lengths of text contain dead space/tabs in the middle of a line of text.
These strategies in Textpad don't work (but that's no big deal because I've never gotten them to work lol):
[:blank:]
[:space:]
[:print:]
Using @ as a placeholder for 1 space, this is the bad boy I hoped would work:
@@{2,}
The idea is to tighten up dead spaces/tabs in the middle of a line by either replacing them with something (example YY) or deleting them altogether.
I've even tried this with "Regular expression" unchecked. No joy. So . . .
Since I want this search/find/replace string to be durable, I'd like it to apply to anything alpha, numeric, symbol, glyph etc. no matter what kind of symbol, globally.
Thanks guys.
These strategies in Textpad don't work (but that's no big deal because I've never gotten them to work lol):
[:blank:]
[:space:]
[:print:]
Using @ as a placeholder for 1 space, this is the bad boy I hoped would work:
@@{2,}
The idea is to tighten up dead spaces/tabs in the middle of a line by either replacing them with something (example YY) or deleting them altogether.
I've even tried this with "Regular expression" unchecked. No joy. So . . .
Since I want this search/find/replace string to be durable, I'd like it to apply to anything alpha, numeric, symbol, glyph etc. no matter what kind of symbol, globally.
Thanks guys.
Trump.
Jesus wept.
Jesus wept.
See what I mean MG?Cannot find regular expression:Cannot find regular expression:Code: Select all
@@{2,}Cannot find regular expression:Code: Select all
@[2,]Code: Select all
@{2,@}
Trump.
Jesus wept.
Jesus wept.
SKYE McLAUGHLIN wrote:I already explained this one before ...Cannot find regular expression:Code: Select all
@@{2,}
SKYE McLAUGHLIN wrote:This matches @2 or @,Cannot find regular expression:Code: Select all
@[2,]
as [2,] matches one character that is either a 2 or a comma.
I am not sure whether a space is allowed between , and }SKYE McLAUGHLIN wrote:Cannot find regular expression:Code: Select all
@{2,@}
Thus, this is either invalid (not a regex), or it is the same as @{2,}
Btw, why do you use that extremely old 5.0.3?
The example I gave with braces [ instead of brackets { was a typo on my part. Here it is corrected:
That makes two of us!
I'm going to spell out the string you recommended above:
At no time should you feel that I am challenging your expertise MudGuard. You remain one of a small handful of coding experts whose advice I have greatly benefited from over the years. Your advice is unimpeachable and as I have thanked you many, many times before, I thank you once again. If there were a way I could upload a screenshot of each of these rejected attempts I would because I am painfully aware that you must think I'm off my nutCannot find regular expression:Code: Select all
@{2,}
I'm going to spell out the string you recommended above:
If that is the exact string it does not work. I'm still on 5.0.3 because when I attempted to upgrade to 7 it was rife with errors and instability. I've never had a problem with 5.you probable wantCode: Select all
space left.bracket number.2 comma right.bracket
Trump.
Jesus wept.
Jesus wept.
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Those character class expressions are enclosed by (square) brackets, not (curly) braces. And they can be used only within character sets, which are themselves enclosed by (square) brackets, like this:
[[:blank:]]
[[:space:]]
[[:print:]]
The expression [:blank:] not within brackets matches any one of the characters
: (colon), b, l, a, n, k.
Have any of your regexes acquired unwanted spaces at their right-hand ends?
[[:blank:]]
[[:space:]]
[[:print:]]
The expression [:blank:] not within brackets matches any one of the characters
: (colon), b, l, a, n, k.
Have any of your regexes acquired unwanted spaces at their right-hand ends?
Wow, did I have that one wrong.ben_josephs wrote:The expression [:blank:] not within brackets matches any one of the characters
: (colon), b, l, a, n, k.
Have any of your regexes acquired unwanted spaces at their right-hand ends?
Trump.
Jesus wept.
Jesus wept.
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Yes Ben and that exact string works for locating one space/tab etc. Everyone on the forum has been so helpful to me, and I just can't get it to work.ben_josephs wrote:Did you try a regex search using [[:space:]] ?
It is such a simple thing:
Find 2 or more spaces or tabs.
I should be able to find it in Textpad Help. I can't.
I should be able to Google it if (for whatever reason) the examples given on the forums here aren't working.
Every site I've visited hoping to see an explicit example either has examples for 1 space/tab . . . or buried in a string so complicated my eyes glaze over.
I can get @@+ to work, but only on spaces. Is there a way I can get it to match either spaces or tabs? I'm sorry, I know you are all trying to help me.
Trump.
Jesus wept.
Jesus wept.
Any of the following will do it:SKYE McLAUGHLIN wrote:It is such a simple thing:
Find 2 or more spaces or tabs.
[@\t][@\t]+
[@\t]{2,}
[[:blank:]][[:blank:]]+
[[:blank:]]{2,}
The pattern \t matches a tab, so [@\t] matches a space or a tab.
The character class [:blank:] matches a space or a tab (if used within a character set like [[:blank:]] as ben_josephs explained above).
These are listed in the help file under Tabs and Character Class Operators respectively.
