Posts: 2,556
Threads: 120
Joined: Sep 2012
Is this possible? How would the regex look?
I was tinkering in mechanics trying to figure out if I could send messages to the intercoms by prefixing a string with :in
couldn't figure out how because I have no idea how to regex.
e.g microphone component text >> regex add :in >> speaker component ":in blah blah blah" >> intercom "blah blah blah"
Posts: 1,174
Threads: 73
Joined: Sep 2014
Speaking of regex, someone should really find a guide for it on the internet and link it to the relevant parts of the MechComp tutorial.
Posts: 577
Threads: 72
Joined: Dec 2013
BYOND Username: Erev
I just tried a simple setup using a button and a sound synth. Not only does :in MESSAGE not work, but neither does turning on the intercomm's microphone manually and then using the sound synth to play a normal HONK!!! It is probably set up that way to prevent spamming but it would be nice to be able to interface with the intercomms.
Posts: 31
Threads: 0
Joined: Nov 2014
BaneOfGiygas Wrote:Speaking of regex, someone should really find a guide for it on the internet and link it to the relevant parts of the MechComp tutorial.
Most Regex's operate in vaugely the same way, so any regex tutorial should help out at least somewhat. I found the one on RegexOne to be particularly helpful when I had to learn it for a class. I figure I could type up a small tutorial for it given a few days.
Posts: 2,552
Threads: 33
Joined: Oct 2014
With regards to regex, it's not really that useful to know more than the basics. I only tend to use things like:
Any digit: \d
Any letter: \w
Any single char: .
Character escape: \
Any three digits: \d{3}
Any amount of digits: \d*
Three to nine letters: \w{3,9}
Three or more of any letter: \w{3,}
The case-sensitive word "fArTe": fArTe
The case-insensitive word "FaRtE": [Ff][Aa][Rr][Tt][Ee]
Only the case-sensitive words "fArTe" and "FaRtE": fArTe|FaRtE
A letter in the range from a to f, and a number in the range from 7 to 9: [a-f][7-9]
NOT a letter in the range from a to f, and a number in the range from 7 to 9: [^a-f][^7-9]
I really don't use more than these. For instance: /.*[Ff][Aa][Rr][Tt][Ee]-\d{3}.*/ will match and return any sequence of any characters that include the pattern of a case-insensitive word farte, a dash, and any 3 digits. Say, afs45ak-3SAsjffartE-420, would return but, fasdj hfksf FARTE-4200 asbut, wouldn't.
Posts: 1,246
Threads: 15
Joined: Oct 2012
The case insensitive word '[Ff][Aa][Rr][Tt][Ee]': /farte/i
Posts: 2,552
Threads: 33
Joined: Oct 2014
Marquesas Wrote:The case insensitive word '[Ff][Aa][Rr][Tt][Ee]': /farte/i
Hmm. I'm pretty sure I tried that flag. I'mma hop on and test it again.
Yeah. /farte/i doesn't work for me. Interestingly enough, /[f][a][r][t][e]/i does.
Posts: 1,246
Threads: 15
Joined: Oct 2012
I might have this forwarded to Lummox (he wrote the regex lib) cause that is just plain Dumb.
Posts: 699
Threads: 155
Joined: Sep 2013
Good luck with that, it hasn't been updated in years.
Posts: 1,246
Threads: 15
Joined: Oct 2012
Wrong, Wire recently got Lummox to take a look at one of the bugs he ran into.
Posts: 784
Threads: 45
Joined: Jan 2016
Fixed it too! I was proud of that one.