RegEx compilation thread

    Fellow Starmadian

    Oh cool so thats what this is
    Joined
    Jun 7, 2014
    Messages
    227
    Reaction score
    87
    • Community Content - Bronze 1
    • Wired for Logic
    • Legacy Citizen 2
    So I made something, assuming you'd want to use the format described in your latest post, with some edits. Instead of your format, I have modified it slightly to read as this: :PlayerPoints1.300]:PlayerPoints2[500]:PlayerPoints3[700]: Simply because it's the one I chose for testing, it takes time to account for all those extra spaces, plus having a spacer character at the beginning and the end makes things easier.

    I assume you want the regex to: Be able to categorize the variable name, display the value stored in the variable, and then change the variable.

    note that much of this is just for future reference.
    -separate number from variable: Regex101 - online regex editor and debugger
    (this code can be optimized, but it was intended for something else possibly later)
    -cut off number from variable: Regex101 - online regex editor and debugger
    -turn modified number into [add] regex and add to end of variable: Regex101 - online regex editor and debugger

    This should accomplish most of the functionality, see if this is along the lines of what you wanted. If not please explain and I'll make the changes.

    Q. Do you already have the regex for separating your variables so you can test one at a time? There are tons of ways to do it, my string parser being only one method.

    Here's one I just thought up, I'm too tired to finish it tonight though... I thought of using a modified regex counter to change the $ command after the [with] to the next number up / down. Then using quite specific regEx you can have it select the next field and copy it into the input of a display shift register.
     

    Attachments

    • Like
    Reactions: Jaaskinal
    Joined
    Jul 30, 2013
    Messages
    398
    Reaction score
    282
    • Wired for Logic Gold
    • Legacy Citizen 8
    • Purchased!
    Thanks for the reply, I will explain better what I have done and what I need.
    This is the regex command i use for "save" and "access" the data:

    This is for "add the name" of the first player (same mechanic for the other players OR other kind of information )
    Code:
    [ADD]PlayerPoints1[...]
    This allows me, make a back reference to the right player, and save his points ( using this method, you can link a infinite number of display blocks where the info can be saved in line or vertical)
    Code:
    [REPLACEFIRST]PlayerPoints1\[(.+?)\][WITH]PlayerPoints1[300]
    Now the difficult part, I can make a simple backk reference to one specific player, and capture only his punctuation, but I need the function for erase all the data of a display block, and leave only that value:
    This remove the name of the selected player except the capture info between [...]
    Code:
    [REPLACEFIRST]PlayerPoints1\[(.+?)\][WITH]$1
    But if i have all the info of diferent players in one display block or more ( PlayerPoints1[300],PlayerPoints2[500],PlayerPoints3[700]... ), i need a regex command for remove ALL other text present except the info of the player1, for get this result
    Code:
    display block 1: regex command
    display block 2: PlayerPoints1[300],PlayerPoints2[500],PlayerPoints3[700]
    
    click one button
    
    display block 1: regex command
    display block 2: 300
    I hope it has become clearer what my goal is, and see the potential of this system, you can store all the info you want and with a few regex command, save and read it :)
     
    Last edited:

    Thalanor

    CEO Snataris Colonial Fleetyards
    Joined
    Sep 10, 2013
    Messages
    818
    Reaction score
    708
    • Master Builder Bronze
    • Thinking Positive
    • Legacy Citizen 3
    This is unfortunately not within the scope of what pure regex can do for you unless schema manually implements such functionality.

    For example, say, this is your text: aaaaBBBcc
    Now what you want is an [EXTRACT]BBB, which is a [REMOVEALL]aaaa[AND]cc[AND]...
    This is not an atomar operation anymore and might even require multiple [AND]s, which translate directly to multiple commands and you need to know beforehand what you want to remove. Everything a regex is supposed to be able to remove must be "in one piece", e.g. a continuous pattern. It can't "find" things that are "fragmented".
    It gets even more complex in your case with "address" and "data" part of the same substring which in turn is part of the same display block content string.
     
    Last edited:
    • Like
    Reactions: GalactusX
    Joined
    Jan 11, 2017
    Messages
    168
    Reaction score
    83
    1: Copy the original statement onto a second display block.
    2: Use "[REPLACEFIRST]regex[WITH]temp" on the second display block.
    3: Use a sensor to determine if they are the same.
    4a: If they are the same, the text did not contain "regex".
    4b: If they are not the same, the text contained the word "regex", output "regex" onto another display block.
    This is awesome! Thank you!
    This regex allowed me to make more flexible entry commands for my logic core.

    With my old command towers, you had to type in the exact phrase to trigger any functions. So {SPOOL WARP COIL} would start your chain drive but "Turn warp drive on" would get you the "I don't recognize that command" prompt.
    With THIS, I can now set up a tower to not only recognize certain words in a sentence but recognize when they're used in conjunction! So while the tower on the right will only function with {SPOOL WARP COIL}, the one on the left will trigger if your command contains the word "warp" in conjunction with the words "activate" or "on". I can then make another 'warp' tower which recognized "warp" and "deactivate" or "off". :)

    The only issue is that this tower takes up a LOT more space, so this level of responsiveness might be limited to stations. Otherwise, my logic core could quickly become absolutely HUGE, and thus unreasonable for the average ship. As it is my logic core is already something like 40*30*9...
     
    Last edited:
    Joined
    Jan 11, 2017
    Messages
    168
    Reaction score
    83
    This is awesome! Thank you!
    This regex allowed me to make more flexible entry commands for my logic core.

    With my old command towers, you had to type in the exact phrase to trigger any functions. So {SPOOL WARP COIL} would start your chain drive but "Turn warp drive on" would get you the "I don't recognize that command" prompt.
    With THIS, I can now set up a tower to not only recognize certain words in a sentence but recognize when they're used in conjunction! So while the tower on the right will only function with {SPOOL WARP COIL}, the one on the left will trigger if your command contains the word "warp" in conjunction with the words "activate" or "on". I can then make another 'warp' tower which recognized "warp" and "deactivate" or "off". :)

    The only issue is that this tower takes up a LOT more space, so this level of responsiveness might be limited to stations. Otherwise, my logic core could quickly become absolutely HUGE, and thus unreasonable for the average ship. As it is my logic core is already something like 40*30*9...
    Actually, now that I think about it, I could use this concept to create a kind "subject" row. I wouldn't even need to make separate towers for "on" and "off", I'd just need another column in the same tower.
    So the 'Warp' tower could be used to "read" any sentence that contains the word warp, basing it's interpretation of your request on the presence of other key terms in your sentence.
    So for my own system, one example might be "Charge 15 warp cells and activate when full."
    The system would trigger the 'Warp' subject row, which would then register the additional words "charge" "15" and "activate". Charge turns on the rail clock. 15 activates warp cell 15 and every cell in line before it. Activate will automatically trigger the ISR for warp as soon as all cells are either in the "charged" or "offline" states. But those secondary functions can only be triggered of the primary 'root' word (warp) is active.

    I could even include some extra words just to cover the bases. 'Charge' could also be activated by 'Spool' and 'activate' by 'on'. So the same set of functions could be triggered by saying: "Spool the drive and prep for 15 warp jumps. Turn on when ready."

    This ALSO means you could give multiple commands at a time!
    By typing something like: "Trigger red alert and spool the emergency warp drive" you could activate sensors in multiple columns and make the machine perform more than one function simultaneously!

    WOW this bit of code just opened up a LOT of possibilities for me...
     
    Last edited:
    Joined
    Jul 30, 2013
    Messages
    398
    Reaction score
    282
    • Wired for Logic Gold
    • Legacy Citizen 8
    • Purchased!
    After being all day glued to the computer screen, I finally got it; now i have some regex commands for save info and read it from display blocks:

    *NOTE: this is only a example i use for test if regex command work or not*

    for example, we have this text in one display block:
    Code:
    PlayerPoints1[300] PlayerPoints2[400] PlayerPoints3[500] PlayerPoints4[700]

    Now, we want know only what are the points of player 2.

    1º STEP: This regex command delete all the other player name tags "PlayerPoints" and his points "[...]" and it only leaves the selected player
    Code:
    (\n*\w*\s*)PlayerPoints[^2]\[(.+?)\](\n*\w*\s*)
    This part of code " [^2] " indicates the player I want to access the information; if i want access to other player just change number 1,2,3,4...
    Regex101 - online regex editor and debugger

    Doing this, we will get this result in display block 1
    Code:
     PlayerPoints2[400]
    2º STEP: Now, we capture only the value in brackets, which will be the points of the player chosen and erase everything else
    Code:
    (\s*)PlayerPoints1\[(.*?)\](\s*)
    Regex101 - online regex editor and debugger

    And we already have it!!, the result will be the value of the points of the second player, in this case "400"
    I have solved my own problem, thanks to you have made me see it from different perspectives, I hope this helps everyone who is interested :)
     
    Last edited:

    Fellow Starmadian

    Oh cool so thats what this is
    Joined
    Jun 7, 2014
    Messages
    227
    Reaction score
    87
    • Community Content - Bronze 1
    • Wired for Logic
    • Legacy Citizen 2
    This is unfortunately not within the scope of what pure regex can do for you unless schema manually implements such functionality.

    For example, say, this is your text: aaaaBBBcc
    Now what you want is an [EXTRACT]BBB, which is a [REMOVEALL]aaaa[AND]cc[AND]...
    This is not an atomar operation anymore and might even require multiple [AND]s, which translate directly to multiple commands and you need to know beforehand what you want to remove. Everything a regex is supposed to be able to remove must be "in one piece", e.g. a continuous pattern. It can't "find" things that are "fragmented".
    It gets even more complex in your case with "address" and "data" part of the same substring which in turn is part of the same display block content string.
    There is so many ways to do that though, here's one example: Regex101 - online regex editor and debugger
    Code:
    checkit :P
    [replacefirst]:*([a-z]+:*)[with]:
    input: :aaaaBBBcc:
    output: :BBB:
    [doublepost=1486321367,1486320170][/doublepost]
    After being all day glued to the computer screen, I finally got it; now i have some regex commands for save info and read it from display blocks:

    *NOTE: this is only a example i use for test if regex command work or not*

    for example, we have this text in one display block:
    Code:
    PlayerPoints1[300] PlayerPoints2[400] PlayerPoints3[500] PlayerPoints4[700]

    Now, we want know only what are the points of player 2.

    1º STEP: This regex command delete all the other player name tags "PlayerPoints" and his points "[...]" and it only leaves the selected player
    Code:
    (\n*\w*\s*)PlayerPoints[^2]\[(.+?)\](\n*\w*\s*)
    This part of code " [^2] " indicates the player I want to access the information; if i want access to other player just change number 1,2,3,4...
    Regex101 - online regex editor and debugger

    Doing this, we will get this result in display block 1
    Code:
     PlayerPoints2[400]
    2º STEP: Now, we capture only the value in brackets, which will be the points of the player chosen and erase everything else
    Code:
    (\s*)PlayerPoints1\[(.*?)\](\s*)
    Regex101 - online regex editor and debugger

    And we already have it!!, the result will be the value of the points of the second player, in this case "400"
    I have solved my own problem, thanks to you have made me see it from different perspectives, I hope this helps everyone who is interested
    :)
    hey, thats pretty neat! Thats a much more useful solution to the thing I posted for thalanor
    (\n*\w*\s*)PlayerPoints[^2]\[(.+?)\](\n*\w*\s*) it removes everything except the variable name you chose! I think this might be able to replace my string parser as a more powerful, simplified parser. There's plenty of logic to add to the top of the thread, I'll be adding that soon.
    [doublepost=1486321526][/doublepost]also this is very important: You can copy display blocks, you just need to delete and repaste the template!
    [doublepost=1486322822][/doublepost]I should also add that I believe that you still need a way of changing the value in the variable and rewriting back to the storage, so my regEx is still relevant. just add this to a block to add the [add] command to the beginning of the changed variable:
    [replacefirst]:[with][add]:

    I'm starting to add the regex to the thread, but I apologize for restructuring it somewhat. I had to replace the space seperators in GalactusX's code with colons, as they are easier to see. Besides that the regEx followed my format anyway, so it is only a small change.
     
    • Like
    Reactions: Thalanor

    Jaaskinal

    ¯\_(ツ)_/¯
    Joined
    Jan 19, 2014
    Messages
    1,377
    Reaction score
    646
    • Legacy Citizen 4
    • Wired for Logic Gold
    • Thinking Positive
    There is so many ways to do that though, here's one example: Regex101 - online regex editor and debugger
    Code:
    checkit :P
    [replacefirst]:*([a-z]+:*)[with]:
    input: :aaaaBBBcc:
    output: :BBB:
    [doublepost=1486321367,1486320170][/doublepost]
    hey, thats pretty neat! Thats a much more useful solution to the thing I posted for thalanor
    (\n*\w*\s*)PlayerPoints[^2]\[(.+?)\](\n*\w*\s*) it removes everything except the variable name you chose! I think this might be able to replace my string parser as a more powerful, simplified parser. There's plenty of logic to add to the top of the thread, I'll be adding that soon.
    [doublepost=1486321526][/doublepost]also this is very important: You can copy display blocks, you just need to delete and repaste the template!
    [doublepost=1486322822][/doublepost]I should also add that I believe that you still need a way of changing the value in the variable and rewriting back to the storage, so my regEx is still relevant. just add this to a block to add the [add] command to the beginning of the changed variable:
    [replacefirst]:[with][add]:

    I'm starting to add the regex to the thread, but I apologize for restructuring it somewhat. I had to replace the space seperators in GalactusX's code with colons, as they are easier to see. Besides that the regEx followed my format anyway, so it is only a small change.
    If you're looking to add a command to the beginning of a text, I like to use [replacefirst][with][add] since it has no prerequisite for what characters must be contained in the text. You probably already know this, but maybe someone else will find it useful.
     

    Fellow Starmadian

    Oh cool so thats what this is
    Joined
    Jun 7, 2014
    Messages
    227
    Reaction score
    87
    • Community Content - Bronze 1
    • Wired for Logic
    • Legacy Citizen 2
    OK so here's my total solution, completed using lots of reference to GalactusX's regEx. It copies the display module with all the data, cuts it down to a single variable, extracts the value from that value for you to change. with one more button to press, it injects the value back into the variable, then injects the variable back into the data storage display module. It's got a crazy amount of regex so it'll take a long time to convert it to a digital format, so in the mean time here's a picture and an updated regEx compilation bread board.
    (you have to hit the left button twice, don't understand that yet :/)

    you can see to the left, two blocks behind the input panel, is the data storage block.
    [doublepost=1486329304,1486329189][/doublepost]
    If you're looking to add a command to the beginning of a text, I like to use [replacefirst][with][add] since it has no prerequisite for what characters must be contained in the text. You probably already know this, but maybe someone else will find it useful.
    I ddn't know that, eventually I'll add it to the main post under "regex quirks" along with my tip that to get displays from templates to copy right, you just need to delete and repaste the whole template (or just repaste the chunks with display modules)

    yeah that thing is crazy un-optimized, but let's call this a proof of concept, lol. I can't get it right on the first try, but I sure as hell can get it to work.
     
    Last edited:
    • Like
    Reactions: Jaaskinal
    Joined
    Jan 11, 2017
    Messages
    168
    Reaction score
    83
    Since it doesn't seem like anyone else has done this yet, I'm going to start a thread to document all the practical uses in starmade for regEx that I've discovered. Hopefully this will allow people to use the the new features of display blocks without:
    A: Learning regEx.
    B: Depending on a player with a logic badge or equivalent knowledge to help them.

    This isn't to say that learning regEx is bad, as it's actually a good thing. It's not overly difficult either, I spent 4-5 hours studying the language and already I'm starting to understand most of the concepts. But I can totally agree with people that don't want to take the time to learn a new coding language. It's a fairly old and seldom used language. So seldom used in fact that I've found stack overflow pages with a single response to my googled question saying "regex isn't the best for this."

    So to prevent hair pulling and google crusades, here's a frequently updating list of all the practical applications and regex statements I've discovered. I'm sure these aren't nearly optimized, and I will update the different applications as more optimized methods are discovered. I use Regex101 - online regex editor and debugger to test my code in, it's much more useful than testing in starmade because it gives you feedback on what every part of the code does. Still have to test in starmade though because there are quirks that must be overcome.

    p.s. each line is a regex statement that needs to be in its own display block. To edit the contents of a display, put a button or activator next to the display you want to use as the modifier, then V the button to the display module you want to modify.

    I've noticed one thing so far that seems to be a limit in starmade's implementation of regex. normal regex code has multiple groups of matches, and I think people are supposed to be able to select one or the other to edit, but I cannot seem to do this. [replacefirst] seems to just remove everything that was matched. I'm probably just missing something.
    For a long while off and on, I've been trying to create a basic scripting language in starmade, a way to convert sentences into a series of logic commands and have each command activate some logic. To do this, you need two different statements, one to remove the first field (word), and another to remove the last. This example uses : as the word separator, so you can have multiple words in a single field.
    EX: :test: of the: string parsing :system:
    1st statement: Regex101 - online regex editor and debugger
    2nd statement: Regex101 - online regex editor and debugger
    Code:
    removal of first field: (replace number with amount of fields forward you want)
    [replaceall]^(:([^:]*:){2})[with]:
    
    removal of last field (2 steps): (replace number with amount of fields back you want)
    [replaceall](:([^:]*:){2})$[with]:
    I'm sure there is a way to dynamically read each word to a quite extended length, but as of now I only know how to do it statically. for each word you know the sentence will have, you need to run those two bits of code until you have only 1 field left, then store that text. you can do this by making a display shift register.
    This doesn't work properly, I need to find a way to remove the line entirely instead of replacing the line with something else... It's the same as string parsing, but use these two sets of code instead:
    1st statement: Regex101 - online regex editor and debugger
    2nd statement: Regex101 - online regex editor and debugger
    Code:
    to erase the first line:
    ^(.*\n)
    
    to erase the last line:
    (\n.*)$
    Very simple to create with any amount of displays. To set one up, just daisy chain a row of buttons or activators, then place a display block adjacent to each button. At the end of the chain, connect the button to the display block of the next button down the line. Continue all the way back to the beginning of the chain. Put some text in the display block at the end of the chain and press the button at the beginning. Thanks to instant pulses, the buttons are activated one after the other down the chain! The second display updates the first, the third display updates the second, and so on.
    Snapems' logic counter:
    RegEx Logic - Counter
    I actually have yet to figure out how this works, so I'll leave the explaining to Snapems
    1st statement: Regex101 - online regex editor and debugger
    2nd statement: Regex101 - online regex editor and debugger
    (these work with any number, mess around on the website a bit and figure out how to substitute the number in the test string with a different number.
    Code:
    to count up a number in a display block:
    [REPLACEALL]\b([0-9]+)\b[WITH]0$1~01234567890
    [REPLACEALL]\b0(?!9*~)|([0-9])(?=9*~[0-9]*?\1([0-9]))|~[0-9]*[WITH]$2
    1st statement: Regex101 - online regex editor and debugger

    2nd statement: Regex101 - online regex editor and debugger
    3rd statement: Regex101 - online regex editor and debugger (doesnt seem to be neccesary)
    Code:
    to count down:
    [REPLACEALL]\b([0-9]+)\b[WITH]$1~09876543210
    [REPLACEALL]\b0|([0-9])(?=0*~[0-9]*?\1([0-9]))|~[0-9]*[WITH]$2
    (The third statement removes a potential leading 0 from the beginning instead of leaving it there.)
    [REPLACEALL]\b0|([0-9])(?=0*~[0-9]*?\1([0-9]))|~[0-9]*[WITH]$2
    =========================================
    Jaaskinal's hexidecimal counter:
    1st statement: Regex101 - online regex editor and debugger
    2nd statement: Regex101 - online regex editor and debugger


    1st statement: Regex101 - online regex editor and debugger
    2nd statement: Regex101 - online regex editor and debugger
    Code:
    To count up:
    [REPLACEALL]\b([0-F]+)\b[WITH]0$1~0123456789ABCDEF0
    [REPLACEALL]\b0(?!F*~)|([0-F])(?=F*~[0-F]*?\1([0-F]))|~[0-F]*[WITH]$2
    
    To count down:
    [REPLACEALL]\b([0-F]+)\b[WITH]0$1~0123456789ABCDEF0
    [REPLACEALL]\b0|([0-F])(?=0*~[0-F]*?\1([0-F]))|~[0-F]*[WITH]$2
    
    To count up in odd numbers, but also skip odd beginnings:
    [REPLACEALL]\b([0-F]+)\b[WITH]0$1~013579BDF1
    [REPLACEALL]\b0(?!F*~)|([0-F])(?=F*~[0-F]*?\1([0-F]))|~[0-F]*[WITH]$2
    
    To count forwards but also backwards at the same time: (i guess)
    [REPLACEALL]\b([0-F]+)\b[WITH]0$1~0FEDCBA9876543210
    [REPLACEALL]\b0(?!F*~)|([0-F])(?=F*~[0-F]*?\1([0-F]))|~[0-F]*[WITH]$2
    ---------------------------------------------------------------------------------------
    Jaaskinal's binary counter:
    1st statement: Regex101 - online regex editor and debugger
    2nd statement: Regex101 - online regex editor and debugger


    1st statement: Regex101 - online regex editor and debugger

    2nd statement: Regex101 - online regex editor and debugger
    Code:
    To count up:
    [REPLACEALL]\b([0-1]+)\b[WITH]0$1~010
    [REPLACEALL]\b0(?!1*~)|([0-1])(?=1*~[0-1]*?\1([0-1]))|~[0-1]*[WITH]$2
    
    To count down:
    [REPLACEALL]\b([0-1]+)\b[WITH]0$1~010
    [REPLACEALL]\b0|([0-1])(?=0*~[0-1]*?\1([0-1]))|~[0-1]*[WITH]$2
    That's all for now, but I'm currently focusing on regex related logic so there's sure to be more soon!
    Here's the link to the breadboard demonstration for all the regex I'm working on:
    regEx compilation breadboard
    So I'm a bit stuck and need an expert opinion.
    I'm trying to implement the code: Regex.Replace(s, "[^0-9.]", "")
    I want to remove all text from a display that isn't a number. I need this so that my programming mechanism for the warp drive doesn't have to be 25 cells long. XD

    I can't seem to get it to work though. Any avice?

    I tried: ([REPLACEALL][a-z][with] ) to remove the letters, but it won't work. Best I can seem to do is replace letters with symbols, which doesn't help...
    [doublepost=1486390108,1486387383][/doublepost]I MIGHT have found a solution? Maybe?

    [REPLACEALL]:*([\D])*[WITH][ ]
    Seems to consistently give me results in terms of
    [ ][ ]2[ ]5[ ][ ]
    [ ][ ]1[ ]5[ ][ ]
    [ ][ ]1[ ]7[ ][ ]
    Etc... So I should be able to set up the inputs in that format and make it go? I think? Only problem comes when the number in the sentence is at the beginning or the end... Gods, this is way more of a pain than I thought it would be. Lmao
     
    Joined
    Jul 30, 2013
    Messages
    398
    Reaction score
    282
    • Wired for Logic Gold
    • Legacy Citizen 8
    • Purchased!
    Well, I'm going to tell you a trick I found 1 month ago ... currently the function [REPLACEFIRST] ... [WITH] and [REPLACEALL] ... [WITH] can not replace something, with nothing ... BUT We can tell the regex command to replace anything with an "empty field" using references

    For example, if we have this text: "I play StarMade 0.199.429", And I want to erase everything that is numbers, we can use [REPLACEALL][0-9][WITH] ... but it dont work, because it cant replace something, with nothing ... but using this trick, it work:
    Code:
    Text to replace all numbers "I play StarMade 0.199.429"
    [REPLACEALL][0-9.]()[WITH]$1
    Result "I play StarMade"
    Regex101 - online regex editor and debugger
    Why does this work? We first select the range of characters we want [0-9.], Everything in brackets will be taken as coincidence, then we "create" an empty group using (), and finally, we tell the command that uses the created group (which is empty) to replace everything that has coincided using $1 reference.

    A little trick with which you can do great things
     
    Last edited:

    Fellow Starmadian

    Oh cool so thats what this is
    Joined
    Jun 7, 2014
    Messages
    227
    Reaction score
    87
    • Community Content - Bronze 1
    • Wired for Logic
    • Legacy Citizen 2
    heh, that's pretty awesome. I'll be working on the thread tonight, so I'll add your trick and all the other stuff that's been discussed then.
     
    • Like
    Reactions: GalactusX

    Fellow Starmadian

    Oh cool so thats what this is
    Joined
    Jun 7, 2014
    Messages
    227
    Reaction score
    87
    • Community Content - Bronze 1
    • Wired for Logic
    • Legacy Citizen 2
    Updated the main post a little bit, still have a lot of work to do though. Added the tips I could find while waiting for my C# teacher to teach me something new :/

    I urge people to post more regEx related questions, as it seems we have a couple people on the ball answering them... Before I even get a chance to look at the thread ):<

    Seriously though, thanks guys/girls for answering questions so quickly.
     
    Joined
    Jan 11, 2017
    Messages
    168
    Reaction score
    83
    Well, I'm going to tell you a trick I found 1 month ago ... currently the function [REPLACEFIRST] ... [WITH] and [REPLACEALL] ... [WITH] can not replace something, with nothing ... BUT We can tell the regex command to replace anything with an "empty field" using references

    For example, if we have this text: "I play StarMade 0.199.429", And I want to erase everything that is numbers, we can use [REPLACEALL][0-9][WITH] ... but it dont work, because it cant replace something, with nothing ... but using this trick, it work:
    Code:
    Text to replace all numbers "I play StarMade 0.199.429"
    [REPLACEALL][0-9.]()[WITH]$1
    Result "I play StarMade"
    Regex101 - online regex editor and debugger
    Why does this work? We first select the range of characters we want [0-9.], Everything in brackets will be taken as coincidence, then we "create" an empty group using (), and finally, we tell the command that uses the created group (which is empty) to replace everything that has coincided using $1 reference.

    A little trick with which you can do great things
    BRILLIANT!!
    This might solve my problem. Currently my system works just fine so long as the number is in the middle of the sentence, but not the beginning or the end. This might make the input format more flexible if it works.
    THANK YOU!!
     

    Fellow Starmadian

    Oh cool so thats what this is
    Joined
    Jun 7, 2014
    Messages
    227
    Reaction score
    87
    • Community Content - Bronze 1
    • Wired for Logic
    • Legacy Citizen 2
    umm, I made a string parser that already does this :(

    Granted, the way it's applied is different. I'd like to see your design! If it's more efficient/powerful than my string parser I'll replace it.
    [doublepost=1486415306,1486415087][/doublepost]ooh, I just had an idea to upgrade my parser actually.. I wont talk about it here, cause all you thunder stealers will post the working design first D:<
     
    Joined
    Jan 11, 2017
    Messages
    168
    Reaction score
    83
    umm, I made a string parser that already does this :(

    Granted, the way it's applied is different. I'd like to see your design! If it's more efficient/powerful than my string parser I'll replace it.
    [doublepost=1486415306,1486415087][/doublepost]ooh, I just had an idea to upgrade my parser actually.. I wont talk about it here, cause all you thunder stealers will post the working design first D:<
    I'm sorry.
    I'm pretty new to this field, it's possible I saw it and didn't realize what it did. Do you have a link? Or is it back in the main post?
    [doublepost=1486416053][/doublepost]
    umm, I made a string parser that already does this :(

    Granted, the way it's applied is different. I'd like to see your design! If it's more efficient/powerful than my string parser I'll replace it.
    [doublepost=1486415306,1486415087][/doublepost]ooh, I just had an idea to upgrade my parser actually.. I wont talk about it here, cause all you thunder stealers will post the working design first D:<
    Oh wait! Are you referring to the big machine you made for Galacticus up above? That seemed a lot more complicated than what I need to do.
    [doublepost=1486416501][/doublepost]
    Well, I'm going to tell you a trick I found 1 month ago ... currently the function [REPLACEFIRST] ... [WITH] and [REPLACEALL] ... [WITH] can not replace something, with nothing ... BUT We can tell the regex command to replace anything with an "empty field" using references

    For example, if we have this text: "I play StarMade 0.199.429", And I want to erase everything that is numbers, we can use [REPLACEALL][0-9][WITH] ... but it dont work, because it cant replace something, with nothing ... but using this trick, it work:
    Code:
    Text to replace all numbers "I play StarMade 0.199.429"
    [REPLACEALL][0-9.]()[WITH]$1
    Result "I play StarMade"
    Regex101 - online regex editor and debugger
    Why does this work? We first select the range of characters we want [0-9.], Everything in brackets will be taken as coincidence, then we "create" an empty group using (), and finally, we tell the command that uses the created group (which is empty) to replace everything that has coincided using $1 reference.

    A little trick with which you can do great things
    Sadly, after testing this, it has the exact same problem. Once I remove the letters spaces are left over instead of the brackets. This means that it's fine so long as the number is mid sentence, but it won't accept the command if the number comes first or last.
     
    Joined
    Jul 30, 2013
    Messages
    398
    Reaction score
    282
    • Wired for Logic Gold
    • Legacy Citizen 8
    • Purchased!
    I'm sorry.
    I'm pretty new to this field, it's possible I saw it and didn't realize what it did. Do you have a link? Or is it back in the main post?
    [doublepost=1486416053][/doublepost]

    Oh wait! Are you referring to the big machine you made for Galacticus up above? That seemed a lot more complicated than what I need to do.
    Easier than the mechanism of a pacifier
     
    • Like
    Reactions: Stormraven
    Joined
    Jan 11, 2017
    Messages
    168
    Reaction score
    83
    Easier than the mechanism of a pacifier
    Sadly, it still leaves spaces behind in their place. For the purpose of using sensors to search for an exact number match, this solution has the same problem mine did.
     
    Joined
    Jul 30, 2013
    Messages
    398
    Reaction score
    282
    • Wired for Logic Gold
    • Legacy Citizen 8
    • Purchased!
    Give me a moment.. you want remove spaces too?
    Code:
    Text to replace all numbers "I play StarMade 0.199.429"
    [REPLACEALL][0-9. ]()[WITH]$1
    Result "IplayStarMade"
    Easy to solve, just add one "space" between the square brackets [0-9. ]
    Remember, everything inside the brackets will be detected, and the regex command will delete it thanks to the empty group back-reference
     
    Last edited:
    Joined
    Jan 11, 2017
    Messages
    168
    Reaction score
    83
    Give me a moment.. you want remove spaces too?
    Code:
    Text to replace all numbers "I play StarMade 0.199.429"
    [REPLACEALL][0-9. ]()[WITH]$1
    Result "IplayStarMade"
    Easy to solve, just add one "space" between the square brackets [0-9. ]
    Holy crap! That's all it took?! Lmao. Nice!
    Thank you! Much appreciated!
    This will make my programmable warp drive much more stable. :)

    Now I can enter "Spool warp coils and prepare for 24 jumps"
    The computer will apply [REPLACEALL][A-Z.a-z.]()[WITH]$1
    And punch out: 24 which is the trigger for that particular warp cell.
    Beautiful!
     
    Last edited:
    • Like
    Reactions: GalactusX