Regex and Replace

Jan 30, 2010
21
0
Appreciate any help with getting @REGEX to work with @REPLACE.
I have a large file and I want to convert all whitespace to commas
I can use set bb=%@replace[^ ,^,,%bb]
gets rid of the biggest problem but there are lots of other spaces so I need to integrate regex with a replace.
echo set vt %@REGEX[[ \t]+|[ \t], %bb]
returns '1' but thats pretty useless information.
I can do this with RegexBuddy but hoped to discover a method of using regex in TCC.
 
May 20, 2008
11,388
99
Syracuse, NY, USA
On Wed, 10 Feb 2010 06:26:17 -0500, bravotango <> wrote:

|Appreciate any help with getting @REGEX to work with @REPLACE.
|I have a large file and I want to convert all whitespace to commas
|I can use set bb=%@replace[^ ,^,,%bb]
|gets rid of the biggest problem but there are lots of other spaces so I need to integrate regex with a replace.
|echo set vt %@REGEX[[ \t]+|[ \t], %bb]
|returns '1' but thats pretty useless information.
|I can do this with RegexBuddy but hoped to discover a method of using regex in TCC.

@XREPLACE in my 4UTILS plugin may help you. Here's a small example.

v:\> echo %@xreplace["[ \t]*",^c,My dog has fleas.]
My,dog,has,fleas.
--
- Vince
 
May 20, 2008
603
0
Sammamish, WA
Vince: ftp://lucky.syr.edu/4plugins/vc9/sysutils.zip appears to have os.txt
inside and not sysutils.txt inside. Is that intended?

On Wed, Feb 10, 2010 at 6:45 AM, vefatica <> wrote:


> On Wed, 10 Feb 2010 06:26:17 -0500, bravotango <> wrote:
>
> |Appreciate any help with getting @REGEX to work with @REPLACE.
> |I have a large file and I want to convert all whitespace to commas
> |I can use set bb=%@replace[^ ,^,,%bb]
> |gets rid of the biggest problem but there are lots of other spaces so I
> need to integrate regex with a replace.
> |echo set vt %@REGEX[[ \t]+|[ \t], %bb]
> |returns '1' but thats pretty useless information.
> |I can do this with RegexBuddy but hoped to discover a method of using
> regex in TCC.
>
> @XREPLACE in my 4UTILS plugin may help you. Here's a small example.
>
> v:\> echo %@xreplace["[ \t]*",^c,My dog has fleas.]
> My,dog,has,fleas.
> --
> - Vince
>
>
>
>
>



--
Jim Cook
2010 Sundays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Monday.
 
May 20, 2008
11,388
99
Syracuse, NY, USA
On Wed, 10 Feb 2010 11:18:14 -0500, Jim Cook <> wrote:

|Vince: ftp://lucky.syr.edu/4plugins/vc9/sysutils.zip appears to have os.txt
|inside and not sysutils.txt inside. Is that intended?

Obviously not. I fixed it.
--
- Vince
 
Jan 30, 2010
21
0
Thanks Vince. That looks more like what's needed. Took me all day to find the latest version or 4utils plugin but your example works.
However if I change it to read my string:
echo %@xreplace["[ \t]*",^c,%bb]
I get error 'Parameter incorrect'
 
May 20, 2008
11,388
99
Syracuse, NY, USA
On Thu, 11 Feb 2010 00:18:54 -0500, bravotango <> wrote:

|Thanks Vince. That looks more like what's needed. Took me all day to find the latest version or 4utils plugin but your example works.
|However if I change it to read my string:
|echo %@xreplace["[ \t]*",^c,%bb]
|I get error 'Parameter incorrect'

You can always find the newest at ftp://lucky.syr.edu/4plugins/vc9.

There may be problematic characters in %bb (or maybe it's empty). I find no
problem using a variable in the third parameter.

v:\> set zz=My dog has^tfleas.

v:\> set zz
My dog has fleas.

v:\> echo %@xreplace["[ \t]*",^c,%zz]
My,dog,has,fleas.
--
- Vince
 
Jan 30, 2010
21
0
On Thu, 11 Feb 2010 00:18:54 -0500,

v:\> set zz=My dog has^tfleas.

v:\> set zz
My dog has fleas.

v:\> echo %@xreplace["[ \t]*",^c,%zz]
My,dog,has,fleas.
--
- Vince

Sorry Vince, I messed my script up by inappropriate use of ECHO.
Your solution is the ants pants and thanks for your help.

Bazza
 
Similar threads
Thread starter Title Forum Replies Date
F %@regex["^-","-a"] returns 0, "^-" =~ "-a" is false (no match) Support 4
JohnQSmith Regex renaming Support 2
vefatica TPIPE: unbalanced escaped quotes in a regex? Support 5
rps Regex problem: \xnn not recognized as a hex character Support 0
old coot Regex problem: \xnn not recognized as a hex character Support 12
R Regex using ^ Support 2
T Regex engine doesn't recognize native DOS line endings Support 2
P Simple RegEx copy Support 9
samintz WAD Regex Analyzer Support 1
D How to? Use typed envars using regex. Support 3
P Renaming with a RegEx Support 1
R How to? use @everything perl regex Support 2
C v18 regex help please Support 1
C Font of RegEx Analyzer Support 0
D Regex problem Support 17
mikea How to? Regex match when there shouldn't be (?) Support 18
JohnQSmith Fixed Copying with regex (several issues) Support 7
D Help needed to get a regex to work Support 3
thedave WAD Regex match on \h Support 5
Ville Regex & conditionals Support 9
samintz Regex Rename Support 2
vefatica @REGEX: behavior vs. documentation Support 2
vefatica @REGEX revisited Support 4
vefatica @REGEX question Support 6
vefatica Regex question Support 5
Stefano Piccardi detecting BOM, FFIND multibyte regex Support 18
dcantor FFIND syntax -- is /E"regex" /X supported? Support 2
P Renaming files with regex. Support 6
B "Fun" with DO and Regex Support 12
P Need to use a regex in a "for" loop. Support 54
Joe Caverly Documentation Replace internal command with LIBRARY command Support 0
I how to make TCC default/replace cmd.exe? Support 9
x13 TPIPE /REPLACE - Remove line (including EOL) Support 3
T @replace -- what is wrong here Support 2
C Replace 1st argument on command line Support 4
R How to? Replace in Rename Support 9
C How to? @replace[a comma,_,filename] Support 5
MickeyF Can't get my TPIPE /replace to work Support 4
C @replace and @xreplace problems Support 5
C How to? Replace &'s in filenames / FixNames.dll Support 2
M I'm unable to use @replace[] with a % character in string2 Support 12
MikeBaas Strange prob with %@replace.. Support 4
vefatica Back-refs in TPIPE's /replace's replacement string? Support 2
Frank @replace works case sensitive Support 5
J @replace weirdness Support 1
vefatica TPIPE /replace? Support 3
Stefano Piccardi replace tcc process space? Support 8
vefatica @SUBST ... how replace character with a caret? Support 9
mdwyer @replace - global use in a text file Support 3
B REPLACE is good news Support 0

Similar threads