bugGNU Octave - Bugs: bug #37914, regexprep error when replacing...

 
 

bug #37914: regexprep error when replacing "("

Submitter:  None
Submitted:  Thu 13 Dec 2012 11:26:16 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Joerg Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.6.3
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 13 Dec 2012 01:54:10 PM UTC, comment #1: 

The second argument is a pattern, so in this context the '(' is a grouping operator. The escape character is required to treat it as a literal:


octave:1> regexprep('Hello _ ( ) ','\(',')')
ans = Hello _ ) )


See the regexp documentation for more details on patterns.

Axel Mathéi <amathei>
Thu 13 Dec 2012 11:26:16 AM UTC, original submission:  

regexprep returns error when the second input argument contains "(":


regexprep('Hello _ ( ) ','( ','(')
error: regexprep: missing ) at position 2 of expression

octave:2> regexprep('Hello _ ( ) ','( ','_')
error: regexprep: missing ) at position 2 of expression

octave:3> regexprep('Hello _ ( ) ','(','(  ')
error: regexprep: missing ) at position 1 of expression


However, "(" in the third input argument is ok


octave:1> regexprep('Hello _ ( ) ','_ ','_')
ans = Hello _( )
octave:2> regexprep('Hello _ ( ) ','_ ','(')
ans = Hello (( )


Basically the same is true for ")"


octave:3> regexprep('Hello _ ( ) ',')','(  ')
error: regexprep: unmatched parentheses at position 0 of expression
octave:3> regexprep('Hello _ ( ) ',' ) ','(  ')
error: regexprep: unmatched parentheses at position 1 of expression

octave:3> regexprep('Hello _ ( ) ',' _ ',' ))) ')
ans = Hello ))) ( )


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-12-14 rik5 StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code