Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
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
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 29-Jan-2008 13:07
User is offline View Users Profile Print this message


Sjors de Leeuw

Posts: 23
Joined: 18-Apr-2007

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)
Report this to a Moderator Report this to a Moderator
 7-Feb-2008 12:24
User is offline View Users Profile Print this message


Sjors de Leeuw

Posts: 23
Joined: 18-Apr-2007

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?
Report this to a Moderator Report this to a Moderator
 8-Feb-2008 09:26
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

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
Report this to a Moderator Report this to a Moderator
 8-Feb-2008 14:38
User is offline View Users Profile Print this message


Sjors de Leeuw

Posts: 23
Joined: 18-Apr-2007

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
Report this to a Moderator Report this to a Moderator
 8-Feb-2008 14:47
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

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
Report this to a Moderator Report this to a Moderator
 11-Feb-2008 12:57
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

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
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.