Results 1 to 5 of 5
  1. #1
    Newbie
    Join Date
    January 19th, 2006
    Posts
    24
    How to Replace Semicolon within words?
    Hi,

    I have a multi valued field exported from Access in the following format:

    Advertising & Public Relations;Graphic Design & Creative Arts;Marketing & Sales;Media & Broadcasting

    and I want to add a space after the semicolon so that it looks like this:

    Advertising & Public Relations; Graphic Design & Creative Arts; Marketing & Sales; Media & Broadcasting

    I tried to use the replace function but it does not modify or add the space:

    [WM-Field: TargetByIndustry nolink raw replace(";","; ")]


    What is the way to go? Unfortunately the Access field is a multi valued one and when eporting it semicolons with no spaces are delimiting the values automatically. I am not sure how to change this within Access (if ever possible)

    thanks,
    fabio
    Last edited by fabio; September 21st, 2010 at 10:59 PM.

  2. #2
    Affiliate Manager
    Join Date
    January 18th, 2005
    Location
    Los Angeles, California
    Posts
    1,913
    Semicolons are used in replace expressions as delimiters for multiple actions, so the parser is finding the semicolon and trying to sort out how it defines two separate replace actions and apparently just gives up.

    As with similar parses like PHP, characters that have special meaning to the parser can be escaped to communicate to WM that you want to use the literal value of the string ";", not use it as a delimiter between multiple replace instructions.

    In WM you can escape ";", ")", and "(" by preceding it with "\", e.g.:

    [WM-Field: TargetByIndustry nolink raw replace("\;","\; ")]

    A quick review of the code in WebMerge that parses those expressions confirms those escapes are in place, so the tag as I've rewritten it should do what you need.

    I also just noticed that this escape option is not currently documented in v2.6; this will be corrected in v2.7.

    Thanks for the report.
    Richard Gaskin
    Developer of WebMerge: Publish any data feed on any site
    http://www.fourthworld.com

  3. #3
    Newbie
    Join Date
    January 19th, 2006
    Posts
    24
    Great, Thanks Richard.

  4. #4
    Newbie
    Join Date
    January 19th, 2006
    Posts
    24
    I tried with
    [WM-Field: TargetByIndustry nolink raw replace("\;","\; ")]
    but it does not work. I still get:
    Advertising & Public Relations;Graphic Design & Creative Arts;Marketing & Sales;Media & Broadcasting

    with no spaces after semicolon.
    Not sure what the problem is...

    fabio

  5. #5
    Affiliate Manager
    Join Date
    January 18th, 2005
    Location
    Los Angeles, California
    Posts
    1,913
    Thanks for the details, Fabio. I'll look into the parsing code and see if I can make that as bit more flexible, but my hunch is that there's a limitation in the way it's parsing that might lend itself to this workaround in the meantime:

    [WM-Field: TargetByIndustry nolink raw replace("\;" , "\;"&space )]

    The ampersand concatenates the expression, and "space" is among the constants that should be supported there.

    Copy that as I've shown it here, since if my hunch is correct the extra spaces I've added might help the parser in breaking down that particular expression.

    Let me know how it goes, and I'll report back when I get that enhanced.
    Richard Gaskin
    Developer of WebMerge: Publish any data feed on any site
    http://www.fourthworld.com

  6. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Replace Command
    By wow100 in forum WebMerge (Fourthworld.com)
    Replies: 1
    Last Post: November 11th, 2009, 05:48 PM
  2. How can I replace commas. Replace wont' do it
    By sotonman in forum WebMerge (Fourthworld.com)
    Replies: 8
    Last Post: April 25th, 2007, 04:37 AM
  3. Replace Tag
    By misterdave in forum WebMerge (Fourthworld.com)
    Replies: 1
    Last Post: February 26th, 2007, 11:58 AM
  4. replace semicolons
    By seastwood in forum WebMerge (Fourthworld.com)
    Replies: 1
    Last Post: May 11th, 2006, 06:06 AM
  5. When to replace a program...
    By Eathan in forum Midnight Cafe'
    Replies: 11
    Last Post: May 3rd, 2006, 11:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •