Getting Regex Expressions to work

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • I'm trying to get a regex replace to format a time string by removing the leading zeros. I thought that this would work, but it's not. Any idea what I'm doing wrong?

    ReplaceSRF$( "Regular Expressions object", TimeString$( "TimeString Object", "%I:%M:%S PM" ), "0?(:?\d|[1-9]\d):0?(:?\d|[1-9]\d):0?(:?\d|[1-9]\d) (:?AM|PM)", "${1}:${2}:${3} ${4}" )

    Thanks!

    Ben

    Please login to see this attachment.

    Edited once, last by bholtzman: The file attachment was in the wrong place. (October 21, 2015 at 12:30 PM).

  • I'm not that good at regex syntax so unable to check right now XD,
    but why don't you parse the time string to get each separate number,
    and then build a new string converting numbers to val() and then back to string again (if needed), shouldn't that be quicker (at least, to code correctly)?

    i.e. something like:

    1 - split string ("my time") with delimiter ":"
    2 - set "newtime" to str$(val(getstring("tokenizer",0))) + ": + str$(val(getstring("tokenizer",1))) + ":" + str$(val(getstring("tokenizer",2)))

    edit:
    also, if timestring includes " AM/PM", just feed to the tokenizer:
    left$("my_string",len("my_string"-3))
    and add: +right$("my_string",2) at the end of newstring

    edit2:
    now that i think upon it,
    you won't even need the tokenizer and do everything with left$/right$ strings,
    since it's fixed length with leading zeroes

    just in case you find this solution suitable

    a selection of my Fusion examples can be found Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!