Search the Community
Showing results for tags 'regular-expression'.
Found 2 results
Inspired by PHP's preg_split. Split string by a regular expression. Also supports the same flags as the PHP equivalent. v1.0.1 Example: #include "StringRegExpSplit.au3" StringRegExpSplit('splitCamelCaseWords', '(?<=\w)(?=[A-Z])') ; ['split', 'Camel', 'Case', 'Words']
Hello altogether, yes I already noticed the StringRegExp AutoIt reference and the very good german tutorial of SEuBo, but nevertheless I would be pleased to get a tip. I have strings like this: 'repair car "do it your self" check' or ' repair car toyota'. There could be none, one or more words in quotation marks. It could be also that no expression is set in quotation marks (-->" "). The words of the string vary. I would like to generate an array like [repair, car, do it your self, check] or [repair, car, toyota]. Expressions in quotation marks (" ") should not be splitted. Probably I could use string split and similar methods to combine the words in quotation marks afterwards. But that's not the way I'd like to do it. I already got this reg-exp to extract just the complete expressions in quotation marks (" ") to seperate these from the rest of the terms: Local $aExtract4 = StringRegExp($sTest4, '.*?"(.*?)".*?',3) Moreover I found this reg-exp to work similar to StringSplit with a " " as a delimiter. This would probably a solution if I didn't like to keep the terms in quotations marks together.... : Local $aExtract8 = StringRegExp($sTest4, '(.+?(?:\s|\z))',3) Nevertheless I failed to find a single reg-exp that is able to met both conditions. I am convincend that it is possible to design a single reg-exp that met both conditions! I already tried different scenarios with operators like or |, the conditional (?(?= ) clause and the use of assertion (Lookahead / -behind) but without success. I would appreciate a hint from an "reg-exp expert" if it's able to solve my problem with a single reg-exp and / or to give me some hints how to do that. Many thanks in advance. Auto42