Sun 25 Mar 2012 04:28:05 AM UTC, comment #4:
Regular expressions come in different varieties. The test site regexpal.com uses Javascript for regular expressions and Javascript has different support and interpretations than the Perl Compatible Regular Expressions (PCRE) that Octave uses. Your best bet is probably to debug the pattern in Octave. Start with a small nucleus of a pattern, such as [XCZF], and slowly add one bit of the pattern at a time.
|
Sun 25 Mar 2012 02:16:18 AM UTC, comment #3:
I changed the double quotes to single quotes and the warnings didn't flag as you suggested.
According to http://regexpal.com/, The string is valid, yet incomplete. I need to match:
X[65.989*#101+#103+#525+#127]
C1089.517
Z8.34
F[990.574#1431.275]
As it is the space between the "C to Z" and the "Z to F" is selected. Not an issue I can deblank() the line to trim them.
The "#101+#103+#525+#127" numbers are machine variables. In a separate line I have turned them into variables(VAR101,VAR103,VAR525,VAR127) and initialized them to zero.
The brackets delineate a formula to be evaluated.
What I am pulling out of this line is a set of coordinates to be plotted.
|
Sat 24 Mar 2012 10:30:03 PM UTC, comment #2:
It's true that the interpreter should not crash regardless of the input.
On the other hand, I don't think the search pattern is valid. To begin, the first list atom '[XCZF' is not closed. Second, the pattern is using a lookbehind assertion when I think it needs a lookahead assertion. The four warnings are coming because the pattern is using double quotes and undergoing interpretation. From the regexp documentation,
In this case, I think you meant '\d' to match a digit but it is being interpreted as a literal 'd'. The literal character "\[" is reduced to '[' and is creating a new list atom which is really not what you want.
I don't know exactly what you are trying to parse out of your string but the pattern below, which works, might be something to build from. It returns the start positions in the string of an expression which is (X or C or Z or F) followed by, but not included in the match, a bracket or digit, zero or more non-whitespace characters, and an optional closing bracket.
|
Fri 23 Mar 2012 11:50:06 AM UTC, original submission:
I am parsing a text file and when I try this line:
It crashed 3.6.1 and 3.4.3 and 3.2.4
|