octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #35961] regexp causes Crash


From: Rik
Subject: [Octave-bug-tracker] [bug #35961] regexp causes Crash
Date: Sat, 24 Mar 2012 22:30:04 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0

Follow-up Comment #2, bug #35961 (project octave):

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,


Note, it is recommended to quote PAT in single quotes,
rather than double quotes, to avoid the escape sequences being
interpreted by Octave before being passed to `regexp'.


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. 


ptn = '[XCZF](?=(?:[|d)[^s]*]?)'

[a,b,c,d,e,f] = regexp (line, ptn)
a =

    1   31   41   47

b =

    1   31   41   47

c = 
{
  [1,1] = [](0x2)
  [1,2] = [](0x2)
  [1,3] = [](0x2)
  [1,4] = [](0x2)
}
d = 
{
  [1,1] = X
  [1,2] = C
  [1,3] = Z
  [1,4] = F
}
e = 
{
  [1,1] = {}(1x0)
  [1,2] = {}(1x0)
  [1,3] = {}(1x0)
  [1,4] = {}(1x0)
}
f =

  scalar structure containing the fields:






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?35961>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]