User Tag List

Results 1 to 3 of 3

Thread: Getting Regex Expressions to work

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)

    Join Date
    Dec 2014
    Location
    San Diego, CA
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting Regex Expressions to work

    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

    Regex Replace.mfa

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    I'm not that good at regex syntax so unable to check right now ,
    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

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)

    Join Date
    Dec 2014
    Location
    San Diego, CA
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do agree that splitting the text is a possible way to strip the leading zeros. I'm mostly curious about how to get the syntax right, so I understand how to solve this issue in the future.

Similar Threads

  1. expressions
    By Zabooza in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 21st February 2009, 03:15 PM
  2. more regex example
    By felinex in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 11th April 2008, 09:23 AM
  3. regex test program
    By felinex in forum File Archive
    Replies: 1
    Last Post: 11th April 2008, 12:55 AM
  4. Regex Object status?
    By LIJI in forum Vitalize
    Replies: 10
    Last Post: 15th February 2008, 07:13 PM
  5. Two problems (Environment variables & Regex)
    By Anders in forum Extension Developers Lobby
    Replies: 4
    Last Post: 20th February 2007, 08:58 PM

Posting Permissions

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