![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Maximum length for buffer to which regular expression is applied? Topic Summary: error "incorrect regular expression (re_search)" Created On: 29-Jan-2008 13:07 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Hi
When applying a regular expression to a buffer (or string), I get the error "incorrect regular expression (re_search)" The length of the buffer to which the regular expression is applied is 7119 characters. The regular expression to buffers with shorter lengths (e.g. 3000) work as expected. Does anybody know if there is a maximum length of buffers to which regular expressions can be applied? If there is, is there a work-around for this? Thanks and regards, Sjors (I'm using DOORS 8.3) |
|
![]() |
|
![]() |
|
After some additional research, the following simplified regular expression and simplified buffer (only filled with 'x' charaters) reproduces the problem. Run the script for example via Tools-->Edit DXL... dialog.
When changing 4096 to 4095, regular expression executes without error Alternatively, when removing the caret (^) before the 'y' character in the regular expression, it also executes without error. Any ideas? |
|
![]() |
|
![]() |
|
I notice that it works if you remove the dollar symbol from the regular expression.
Maybe this is something to do with matching the end of the buffer. ------------------------- Tony Goodman http://www.smartdxl.com |
|
![]() |
|
![]() |
|
Thanks Tony, you're right, in this particular example it works. When applying the change in the real script however, it turns out that it isn't the solution (apparenly my example was not the best one :-(
the real regular expression was Regexp regExpTest = regexp "^([^@]*)<@@([^@]*)@@>([^~]*)$" which I simplified in the meantime to regexp "^.*<@@([^@]*)@@>.*" this one also doesn't work well. Anyway, the idea is that I'd like to replace <@@text@@>> with something, and <@@text@@> might occur multiple times within the buffer. If you have any ideas that work with large buffers, feel free ![]() |
|
![]() |
|
![]() |
|
Look in help file at contains to see if this works.
ie int contains(Buffer b, string word, int offset) Edited: 8-Feb-2008 at 14:50 by ron lewis |
|
![]() |
|
![]() |
|
Why do you also search for everything either side of the string you want to replace? The Regexp I would use in this situation is simply:
Regexp regExpTest = regexp "<@@([^@]*)@@>" // Just replace "text" Regexp regExpTest = regexp "(<@@[^@]*@@>)" // Replace "<@@text@@>" You said you only want to replace the "text" in "<@@text@@>", so only search for the text and its delimiters, and only match what you want to replace. If you want to lose the delimiters too, move the brackets outside them. Either way, you can use the following to replace the matched text (assuming your Buffer b already exists): if (regExpTest b) { Buffer newbuf = create while (regExpTest b) { newbuf = b[0:start 1-1] "new text" b = b[end 1+1:] } b = newbuf b delete newbuf } On reflection, you may need to check that you really can assign part of a buffer back to itself... A more complicated alternative is given in the attached code, which goes through the pictures in a rich text buffer (from an object for export), and adjusts them so they fit on the exported page. It uses the 'search' perm: bool search (Regexp re, Buffer b, int start [,int finish]) I wrote it when I was new to DXL, and it's mildly painful to look at now, but it works, so I refuse to fix it. ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive Edited: 11-Feb-2008 at 12:58 by Paul Tiplady |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.