I’m having trouble coming up with an RegExKitLite expression that will match. I’m parsing a string and I want it to grab everything till it comes upon the first occurrence of a colon
What would be the expression in RegExKitLite to do that?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This regex will match everything from the start until (but excluding) the first colon:
To include the first colon is as simple as putting it on the end:
So, to use either of those with RegexKitLite, you can do:
Note how there is no parentheses – since * is greedy you can simply use the negated class and use captured group 0 (i.e. the whole match).
It’s worth noting that most languages will include functions that allow you to do this with a regular function, for example
ListFirst(MyString,':')orMyString.split(':')[0]I suspect Objective-C has something similar to this … yep, see here