OpenOffice.org Basic - Search and Replace in code…

View: New views
5 Messages — Rating Filter:   Alert me  

OpenOffice.org Basic - Search and Replace in code…

by Johnny Rosenberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am coding something in OpenOffice.org Calc using the built in Basic
language thing. Now, when I produced about 50 KiB of code I found that
I was not very consistent in how to type things. For example,
sometimes I type like ”BlahBlah=Foo+Bar-3” and sometimes like
”BlahBlah=Foo + Bar - 3”. So I figured that it wouldn't be too hard to
search for patterns using regular expressions for replacing things,
but I failed doing this!

Thing like work perfectly in OpenOffice.org Writer Search and Replace
doesn't seem to work at OpenOffice.org Basic Search and Replace.
One thing that I need to do this, I guess, is things like $1, $2 and
things like that in the Replace field, but all happens is that my
search string is replaces by $1 and $2 respectively. Of course the
Regular Expression checkbox is ticked.

One example:
Search for: ([a-zA-Z0-9\(\)])([\+|\-|\*|\/])([a-zA-Z0-9\(\)])
Replace with: $1 $2 $3

I tried this in OpenOffice.org Writer and it works perfectly.

Before:
a+b
hej(3)+svejs(4)
tjoho(x)+3

After:
a + b
hej(3) + svejs(4)
tjoho(x) + 3

Doing the same thing in OpenOffice.org Basic:

Before:
a+b
hej(3)+svejs(4)
tjoho(x)+3

After:
$1 $2 $3
hej(3$1 $2 $3vejs(4)
tjoho(x$1 $2 $3

Doesn't look very nice to me…

Is this a bug or am I not supposed to do this?

Johnny Rosenberg

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: OpenOffice.org Basic - Search and Replace in code…

by pitonyak :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You should post your code...

On 10/24/2009 06:05 AM, Johnny Rosenberg wrote:

> I am coding something in OpenOffice.org Calc using the built in Basic
> language thing. Now, when I produced about 50 KiB of code I found that
> I was not very consistent in how to type things. For example,
> sometimes I type like ”BlahBlah=Foo+Bar-3” and sometimes like
> ”BlahBlah=Foo + Bar - 3”. So I figured that it wouldn't be too hard to
> search for patterns using regular expressions for replacing things,
> but I failed doing this!
>
> Thing like work perfectly in OpenOffice.org Writer Search and Replace
> doesn't seem to work at OpenOffice.org Basic Search and Replace.
> One thing that I need to do this, I guess, is things like $1, $2 and
> things like that in the Replace field, but all happens is that my
> search string is replaces by $1 and $2 respectively. Of course the
> Regular Expression checkbox is ticked.
>
> One example:
> Search for: ([a-zA-Z0-9\(\)])([\+|\-|\*|\/])([a-zA-Z0-9\(\)])
> Replace with: $1 $2 $3
>
> I tried this in OpenOffice.org Writer and it works perfectly.
>
> Before:
> a+b
> hej(3)+svejs(4)
> tjoho(x)+3
>
> After:
> a + b
> hej(3) + svejs(4)
> tjoho(x) + 3
>
> Doing the same thing in OpenOffice.org Basic:
>
> Before:
> a+b
> hej(3)+svejs(4)
> tjoho(x)+3
>
> After:
> $1 $2 $3
> hej(3$1 $2 $3vejs(4)
> tjoho(x$1 $2 $3
>
> Doesn't look very nice to me…
>
> Is this a bug or am I not supposed to do this?
>
> Johnny Rosenberg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@...
> For additional commands, e-mail: dev-help@...
>
>
>    

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: OpenOffice.org Basic - Search and Replace in code…

by Jan Holst Jensen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrew Douglas Pitonyak wrote:

> You should post your code...
>
> On 10/24/2009 06:05 AM, Johnny Rosenberg wrote:
>> One example:
>> Search for: ([a-zA-Z0-9\(\)])([\+|\-|\*|\/])([a-zA-Z0-9\(\)])
>> Replace with: $1 $2 $3
>>
>> I tried this in OpenOffice.org Writer and it works perfectly.
>>
>> Before:
>> a+b
>> hej(3)+svejs(4)
>> tjoho(x)+3
>>
>> After:
>> a + b
>> hej(3) + svejs(4)
>> tjoho(x) + 3
>>
>> Doing the same thing in OpenOffice.org Basic:
>>
>> Before:
>> a+b
>> hej(3)+svejs(4)
>> tjoho(x)+3
>>
>> After:
>> $1 $2 $3
>> hej(3$1 $2 $3vejs(4)
>> tjoho(x$1 $2 $3
>>
>> Doesn't look very nice to me…
>>
>> Is this a bug or am I not supposed to do this?

I believe that is exactly what Johnny did. I can reproduce it from the
above. Writer reformats the text in a document so the spacing is nicer.
In the Basic code editor the replace action inserts "$1 $2 $3" which is
pretty useless. At least I can conclude that regular expression
search/replace works differently in a Writer text document and in the
Basic editor.

Cheers
-- Jan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: OpenOffice.org Basic - Search and Replace in code…

by Johnny Rosenberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/10/28 Jan Holst Jensen <jan@...>:

> Andrew Douglas Pitonyak wrote:
>>
>> You should post your code...
>>
>> On 10/24/2009 06:05 AM, Johnny Rosenberg wrote:
>>>
>>> One example:
>>> Search for: ([a-zA-Z0-9\(\)])([\+|\-|\*|\/])([a-zA-Z0-9\(\)])
>>> Replace with: $1 $2 $3
>>>
>>> I tried this in OpenOffice.org Writer and it works perfectly.
>>>
>>> Before:
>>> a+b
>>> hej(3)+svejs(4)
>>> tjoho(x)+3
>>>
>>> After:
>>> a + b
>>> hej(3) + svejs(4)
>>> tjoho(x) + 3
>>>
>>> Doing the same thing in OpenOffice.org Basic:
>>>
>>> Before:
>>> a+b
>>> hej(3)+svejs(4)
>>> tjoho(x)+3
>>>
>>> After:
>>> $1 $2 $3
>>> hej(3$1 $2 $3vejs(4)
>>> tjoho(x$1 $2 $3
>>>
>>> Doesn't look very nice to me…
>>>
>>> Is this a bug or am I not supposed to do this?
>
> I believe that is exactly what Johnny did. I can reproduce it from the
> above. Writer reformats the text in a document so the spacing is nicer. In
> the Basic code editor the replace action inserts "$1 $2 $3" which is pretty
> useless. At least I can conclude that regular expression search/replace
> works differently in a Writer text document and in the Basic editor.
>
> Cheers
> -- Jan

I think that Andrew maybe misunderstood me a bit there, and that you
then misunderstood him, but maybe I am wrong. Just in case I am right,
I will just point out that I use the ordinary Ctrl+F search in my code
to replace things. I did NOT write a Search & Replace macro of my own
or anything like that.
All I wanted to do was to make my code look more consistent, making
sure that spaces and things like that are used the same way in all
code of the project, making it easier to read and nicer to look at…

So there is no point to post any kind of code, since the same thing
happens for any kind of text, for example the text I used in my
examples in my original post.

Johnny Rosenberg

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: OpenOffice.org Basic - Search and Replace in code…

by pitonyak :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/28/2009 12:32 PM, Johnny Rosenberg wrote:

> 2009/10/28 Jan Holst Jensen<jan@...>:
>    
>> Andrew Douglas Pitonyak wrote:
>>      
>>> You should post your code...
>>>
>>> On 10/24/2009 06:05 AM, Johnny Rosenberg wrote:
>>>        
>>>> One example:
>>>> Search for: ([a-zA-Z0-9\(\)])([\+|\-|\*|\/])([a-zA-Z0-9\(\)])
>>>> Replace with: $1 $2 $3
>>>>
>>>> I tried this in OpenOffice.org Writer and it works perfectly.
>>>>
>>>> Before:
>>>> a+b
>>>> hej(3)+svejs(4)
>>>> tjoho(x)+3
>>>>
>>>> After:
>>>> a + b
>>>> hej(3) + svejs(4)
>>>> tjoho(x) + 3
>>>>
>>>> Doing the same thing in OpenOffice.org Basic:
>>>>
>>>> Before:
>>>> a+b
>>>> hej(3)+svejs(4)
>>>> tjoho(x)+3
>>>>
>>>> After:
>>>> $1 $2 $3
>>>> hej(3$1 $2 $3vejs(4)
>>>> tjoho(x$1 $2 $3
>>>>
>>>> Doesn't look very nice to me…
>>>>
>>>> Is this a bug or am I not supposed to do this?
>>>>          
>> I believe that is exactly what Johnny did. I can reproduce it from the
>> above. Writer reformats the text in a document so the spacing is nicer. In
>> the Basic code editor the replace action inserts "$1 $2 $3" which is pretty
>> useless. At least I can conclude that regular expression search/replace
>> works differently in a Writer text document and in the Basic editor.
>>
>> Cheers
>> -- Jan
>>      
> I think that Andrew maybe misunderstood me a bit there, and that you
> then misunderstood him, but maybe I am wrong. Just in case I am right,
> I will just point out that I use the ordinary Ctrl+F search in my code
> to replace things. I did NOT write a Search&  Replace macro of my own
> or anything like that.
> All I wanted to do was to make my code look more consistent, making
> sure that spaces and things like that are used the same way in all
> code of the project, making it easier to read and nicer to look at…
>
> So there is no point to post any kind of code, since the same thing
> happens for any kind of text, for example the text I used in my
> examples in my original post.
>
> Johnny Rosenberg
>    
Oh my, yes, I thought that I was reading the dev forum, and I thought
that this was only with respect to a macro. <sigh>

Sorry

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...