1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Regex and Replace

Discussion in 'Support' started by bravotango, Feb 10, 2010.

  1. bravotango

    Joined:
    Jan 30, 2010
    Messages:
    21
    Likes Received:
    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.
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    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
     
  3. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    605
    Likes Received:
    0
    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:




    --
    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.
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    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
     
  5. bravotango

    Joined:
    Jan 30, 2010
    Messages:
    21
    Likes Received:
    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'
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    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
     
  7. bravotango

    Joined:
    Jan 30, 2010
    Messages:
    21
    Likes Received:
    0
    Sorry Vince, I messed my script up by inappropriate use of ECHO.
    Your solution is the ants pants and thanks for your help.

    Bazza
     

Share This Page