RegEx question

0 favourites
  • 2 posts
  • This is probably simple for people that play around with RegEx quite a bit but I am having a hard time wrapping my head around how to make this work properly in C3.

    What I am doing is pulling from a database using PHP and AJAX. I want to dump the result into a text field and then parse that data using RegEx so I can either push it into an array or simply put the "pieces" into different text fields. For example, this is what the LastData would look like:

    "Testing, marker. Apr 15 2018 13:09 Sam smith Apr 15 2018 13:09 Testing, marker, again. Apr 15 2018 14:09 Sam Jones Apr 15 2018 15:09"

    I would like it to look like this:

    "Testing, marker."

    "Apr 15 2018 13:09"

    "Sam smith"

    "Apr 15 2018 13:09"

    Etc.

    Playing around with RegEx on regex101.com I get some results if I use this expression: [\'].+?[\']|[^,]+$ and add the single quotation marks to the strings I want to isolate. But when I test that in C3 all I can manage is searching the data for the first instance of the quotation mark.

    Any help is appreciated!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Okay, I more or less figured it out. Here is my solution if anyone else needs the help:

    I set the text in a text object with the action of "Set text to"

    RegexSearch(LastData, "[\*].+?[\*]+$", "m"[/code:31of9bu9]. I injected an asterisk in the data being retrieved after the date. Then by cutting the text using left() and right() to separate the date and the text string I was able to get it working.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)