Issue 78855 - Search regular expression with "[" and "]"
Summary: Search regular expression with "[" and "]"
Status: CLOSED IRREPRODUCIBLE
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Windows 2000
: P3 Trivial
Target Milestone: ---
Assignee: thomas.lange
QA Contact: issues@api
URL:
Keywords: needmoreinfo, oooqa
Depends on:
Blocks:
 
Reported: 2007-06-25 13:18 UTC by cellma
Modified: 2013-02-24 21:09 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
test with "\[[^\[] *\]". result = "[","[","[" (7.33 KB, application/vnd.oasis.opendocument.text)
2007-08-01 15:25 UTC, cellma
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description cellma 2007-06-25 13:18:59 UTC
I think there is a problem with a regular expression search. I search all words 
between "[" and "]" in a textDocument. Thus, my regular expression is "\[[^\[]
*\]". With GUI version the find function is Ok. But when I try to use the API, 
it do not work correctly. I think that OO finds all words, because if I have 5 
words between "[" and "]", OO gives me 5 TextRange in the result. but when i 
try to get the text with getString() methode, OO alwas gives me "]". If try the 
same search with word between "@" ( with "@[^@]*@" regular expression), OO 
finds all results and when I use the getString() methode it gives me the good 
word.
Comment 1 mbayer 2007-06-25 22:59:46 UTC
cellma: Please specify the version of OOo you are referring to.
Comment 2 cellma 2007-06-26 07:48:47 UTC
Excuse me. It's 2.2 version.
Comment 3 jsc 2007-07-02 08:53:04 UTC
jsc -> tl: seems to be one for the writer
Comment 4 thomas.lange 2007-08-01 09:44:47 UTC
TL->cellma: please also add a sample document, along with the code your are
using to search for the regular expressions. 
Comment 5 cellma 2007-08-01 15:11:48 UTC
String expression = "\[[^\[] *\]"; // "@[^@]*@"
XReplaceable xReplaceable = UnoRuntime.queryInterface(XReplaceable.class, 
mxDoc);
XReplaceDescriptor xRepDesc = xReplaceable.createReplaceDescriptor();
xRepDesc.setSearchString(expression);
xRepDesc.setPropertyValue("SearchRegularExpression", new Boolean(true));
XIndexAcess  resListe = xReplaceable.findAll(xRepDesc);
    ArrayList  xTextRangeListe = new ArrayList();
    for(i=0;i<resListe.getCount();i++){
XtextRange  xTextRange = UnoRuntime.queryInterface
(XTextRange.class,resListe.getByIndex(i));
String val = xTextRange.getString(); //always equals to "["
            xTextRangeListe.add(xTextRange);
       }
Comment 6 cellma 2007-08-01 15:25:32 UTC
Created attachment 47249 [details]
test with "\[[^\[] *\]". result = "[","[","["
Comment 7 Rainer Bielefeld 2007-09-30 12:43:48 UTC
Your macro does not work (I checked with "2.2.1  Multilingual German version WIN
XP: [680m18(Build9161)]"), please attach a sample document with a working macro
in it and some explication why your believe that your macro should work for your
needs.
Comment 8 cellma 2007-10-01 09:16:53 UTC
My code is extracted from java program. It's not a macro and I don't know how 
to program a macro.
This program do work in my application but with "#[^#]*#" as regular 
expression  and not with "\[[^\[] *\]"
That's why I can get all words between # in a document but not between [ and ] !
Comment 9 Martin Hollmichel 2007-11-09 17:27:48 UTC
set target from 2.x to 3.x according to
http://wiki.services.openoffice.org/wiki/Target_3x
Comment 10 stefan.baltzer 2008-10-29 14:17:18 UTC
SBA: This issue has a target set but is still in state of "Unconfirmed".
Please re-check with OOo 3.0 or younger if it is (still) valid.
Then confirm it or set an appropriate resolution.
Thank you.
Comment 11 stefan.baltzer 2008-10-29 14:24:25 UTC
SBA: This issue has a target set but is still in state of "Unconfirmed".
Please re-check with OOo 3.0 or younger if it is (still) valid.
Then confirm it or set an appropriate resolution.
Thank you.
Comment 12 lohmaier 2009-09-27 22:47:47 UTC
worksforme.

Sub findwords
	oDoc = thisComponent
	oSearch = oDoc.createSearchDescriptor()
	oSearch.setSearchString("\[[^\[]*\]")
	oSearch.SearchRegularExpression = true
	oResults = oDoc.findAll(oSearch)
	for i=0 to oResults.count-1
		oMatch=oResults.getByIndex(i)
		print "found: "+ oMatch.getString
	next i
End Sub

works as expected.
Comment 13 lohmaier 2009-09-27 22:48:36 UTC
closing.

Feel free to reopen if you can still reproduce in a current version, but please
provide a complete testcase to ease reproducing the issue.