Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index


At 4:58pm -0500 Sun, 21 Nov 2010, Wols Lists wrote:
On 18/11/10 13:36, Kevin Hunter wrote:
As I assume you're using a regex, you might consider catching this by
doing the search and replace in series.  Here's an example:

1. Catch the 'OUString +?= ...createFromAscii...' case and replace
with 'OUString var( RTL...)'

search: OUString\s*\w+\s*\+?=\s*\S*createFromAscii\(\s*"([^"]*)"\s*\)
replace: $1 $2( RTL_CONSTASCII_USTRINGPARAM( "$4" ))

2. Then go back for a second pass with something like this:

search: ::createFromAscii\(\s*"([^"]*)"\s*\)
replace: $1 $2( RTL_CONSTASCII_USTRINGPARAM( "$4" ))

The solution isn't perfect, as it still misses certain edge cases, but
should at least help a little bit.

Forgive what might be a stupid question, but I've seen

String::createFromAscii

Will version 2 find those, and should they be replaced?

Not a stupid question at all. Regular expressions aren't the most transparent of creatures.

As I wrote the regex, round 2 /will/ find those. Since I don't know if those should be replaced, I assume that they shouldn't be, making this "an edge case". The correct procedure then would be a "Replace and Find" as opposed to "Replace All". This way one inspects every change rather than blindly updating every occurrence.

Thanks for asking!

Kevin

P.S. As an aside, I'll make a minor plug that learning regular expressions makes possible or less mundane *many* tasks in the programming or text processing world, and many editors have regular expression support built-in. Vim, Emacs, jEdit, and Kate (among others) have them by default, while gEdit (among others) has them available via a plugin. If one doesn't know about them, one might be interested in perusing http://www.regular-expressions.info/, or just generically googling.

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.