Jump to content

Recommended Posts

Posted (edited)

Hi everyone,

I'm currently working on a project that involves heavy string manipulation, where I am working with large datasets. There I need to match specific patterns, modify the matches, and then replace the changes back into the string.

I am already mixed the use of StringReplace and StringRegExpReplace, depending where either one is fater (determined that for most of the cases once). Also I am using the case-sensitivity flag/replace count where possible. I tried to also use CLR and calling a C# hoping that that would be faster, but with the overhead it is only faster in some cases.

Are there any other tipps that I can use?

Edited by IronFine
Posted

There is not much you can do using standard String* functions.  Most of them (when modifying the original string) makes a copy of the string.  With small strings, it is not a big deal.  But when it comes to large strings, it can be quite lengthy to execute multiple string operations over a single string.

One method would be to perform in place replacements.  That is quite easy if you replace N characters with some other N characters.  Also it depends where the strings are coming from and where they go (text files ?).  Do they have known formats they are following (like json or xml) ?

Best way to help you, would be for you to provide a real life example, so we can try to look into a solution tailored to your situation.

Posted (edited)

What @Nine said, but beware of this:

13 hours ago, Nine said:

That is quite easy if you replace N characters with some other N characters.

Not that easy.

Windows uses UTF16-LE internally, which means that a "character" (here I mean actually "one Unicode codepoint") can use either one or two 16-bit words. in RAM. Also, don't forget that AutoIt uses a subset of UTF16-LE named UCS-2, allowing full use of the Unicode BMP (Basic Multilingual Plane), i.e. codepoints U+0000 to U+FFFF. Hence, counting "characters" is not trivial.

Common "characters" in non-english languages like à, Ê, ù, ç, ñ, ... can be represented using different normalization forms, see https://en.wikipedia.org/wiki/Unicode_equivalence#Normalization

Moretheless what we, humans, mean by "character" may require more than one Unicode codepoint. This is the difference between glyph (what is displayed by the font renderer) and codepoint (the actual Unicode content). For instance this string

$s = ChrW(0xD83D) & ChrW(0xDC68) & ChrW(0xD83C) & ChrW(0xDFFB) & ChrW(0x200D) & ChrW(0xD83D) & ChrW(0xDC69) & ChrW(0xD83C) & ChrW(0xDFFF) & ChrW(0x200D) & ChrW(0xD83D) & ChrW(0xDC66) & ChrW(0xD83C) & ChrW(0xDFFD)

displays asFamily.jpg.612c083f7d6035e3d48ef2640c31b9a1.jpg in a Unicode-aware environment.

And that is only speaking of valid representations: one may find out-of-spec representations in input strings, spanning representation of what we perceive as a "character" over an unbounded string of Unicode codepoints.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...