none
Regex in small basic RRS feed

  • Question

  • Is there any extensions that allow the use of regular expressions in small basic?

    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Thursday, December 5, 2013 2:38 AM
    Answerer

Answers

All replies

  • LDUtilities.RegexMatch and LDUtilities.RegexReplace
    • Marked as answer by Zock77Editor Thursday, December 5, 2013 5:19 PM
    Thursday, December 5, 2013 9:36 AM
    Moderator
  • Wow! Thanks!

    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Thursday, December 5, 2013 5:19 PM
    Answerer
  • Why isn't it capturing (Alert:\d*) ?

    String = "sjdhue2387sjeduw327ssksAlert:23sidw"
    Array = LDUtilities.RegexMatch(String,"[\w\d]*(Alert:\d*)\w+","False")



    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Thursday, December 5, 2013 9:00 PM
    Answerer
  • I'm not a master of regex, but:

    Your regex returns the whole input string as it should, assuming this check site is also correct.

    Perhaps you want "(Alert:\d*)\w+" ?
    Thursday, December 5, 2013 9:18 PM
    Moderator
  • well parentheses are how you capture things so 

    [\w\d]*(Alert:\d*)\w+

    should capture

    Alert:\d*

    as long as

    [\w\d]*

    preseds it, and

    \w+

    follows it.


    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Friday, December 6, 2013 3:24 AM
    Answerer
  • Does the extension give different results to other regex engines like the one I suggested?

    If they are the same, then the issue is with the regex string input and you should experiment and understand more what regex is doing.  Perhaps ask specific regex questions here.

    If they are different, then please let me know - all this extension does is call the following .Net method and organise the results as an array for SmallBasic.

    http://msdn.microsoft.com/en-us/library/vstudio/b49yw9s8(v=vs.90).aspx

    Friday, December 6, 2013 12:50 PM
    Moderator
  • Sorry, What parenthesis do is to capture it so you can use $1 and $2 for getting that info. can you use these in this extension?

    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Saturday, December 7, 2013 12:01 AM
    Answerer
  • Does the extension give different results to other regex engines like the one I suggested?

    Basically it does what the link I gave does (i.e. the .Net implementation of regex).  It may be possible to extend this but I don't know what you mean and would like a concrete example that does something different using other (not .Net) regex engines so I can see what is different.

    Saturday, December 7, 2013 10:20 PM
    Moderator
  • No it does what is expected.

    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Saturday, December 7, 2013 11:19 PM
    Answerer