Support for regular expression syntax?

My question actually revolves around trying to remove leading zeros in formatted data (like 9.2.11 instead of 09.02.11) -- but the broader question is, does Webvanta script allow for any kind of text processing using regular expression? That'd be a great feature if not.

Thanks,

Jared

Have more questions? Submit a request

4 Comments

  • 0
    Avatar
    Christopher Haupt

    Jared,

    There is a very simple regex format option available for most data access tags (those that return a value). User format="gsub('regex','substitution')" as the attribute.

    The 'regex' part supports most standard PCRE - Perl Compatible Regular Expressions. The formatter was meant for fairly simple expressions, and currently has some shortcomings (e.g. dealing with quotation marks--the quotes are optional around the expression and substitution, but are required if you need to include a comma, for instance).  

    I haven't tested this, but try: 

    gsub( '0?(\d)\.0?(\d)\.(\d{2})', '\1.\2.\3' )
  • 0
    Avatar
    Jared White

    Hi Chris,

    Sorry I didn't respond to your helpful comment. This is good to know! The one problem though is I'm accessing the date field like so:

    w:get name="start_date" format="%m.%d.%y" / >

    So I'm not sure how to format the format...I tried putting this in a variable with w:var ... and then putting format on that, but that didn't work. Thanks in advance if you have any tips about that.

  • 0
    Avatar
    Christopher Haupt

    No worries, from WebvantaScript, you can get that immediately:

    w:get name="start_date" format="%-m.%-d.%y" / >

    Note the minus symbols. 

  • 0
    Avatar
    Jared White

    Awesome. That totally works!

Please sign in to leave a comment.
Powered by Zendesk