I’m feeling especially slow-minded today, and I’ve had enough of trying to decipher puzzles this week. Seems every time I turn around and try to do something “simple”, it’s 5 hours later and I haven’t accomplished anything.
So I’m asking for help.
I want to do the following in JavaScript (JXA, really).
Given a string, and a starting position:
Function 1:
- Does the character at the position match regex “[\w]”?
- If yes, move forward in the string to find the index of the first non-matching character.
- If no, move forward in the string to find the index of the first matching character.
Function 2:
- Does the character at the position match regex “[\w]”?
- If yes, move backwards in the string to find the index of the first non-matching character.
- If no, move backwards in the string to find the index of the first matching character.
Please don’t optimize too much for this specific regex pattern, because I need to do other patterns also. This is just a template to get me started. I’ll use these functions as stated, but I have more I want to do also.
Thanks.
For bonus points, talk to Xcode and:
- Get the “selected character range” of the “front text document”, or a document with a specific name.
- Get the “contents” (the text) of the" front text document"
- Set the selected character range.
As I said, the only reason I’m asking is my brain is out of gas, and I’m plum tuckered out. This has been one of the longest weeks of my life. (Pity party time!!).