Jump to content

StringRegExp reading from end


Recommended Posts

I have some string to get into a large xml file. I begin with regexp, but need some regexp reading from right to left.

I want to find this '<Name>(.*?)</Name><GroupLevel>-1</GroupLevel><DynamicValues>'

My problem is there tons of <Name>xxx</Name> tags before the one I want, which is followed by '<GroupLevel>-1</GroupLevel><DynamicValues>'

So, is there a way to make sre read for the right to left, so it find the name tag just before the grouplevel etc, and not a string for first name tag in the file ?

Thks

Kib

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Link to comment
Share on other sites

Mmm, I think there is. Although that part of RE's is still clouded by fog to me.

To prep for potential example codes in relation to this you could start taking a peek at the following RE site. http://www.regular-expressions.info/

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

I don't see your point. With a pattern like the one you shown, the match only returns the last one:

Pattern '<Name>(.+?)</Name>\s*<GroupLevel>-1</GroupLevel><DynamicValues>'

Input:

<Name>abc</Name>

<Name>abcd</Name>

<Name>abcde</Name>

<Name>abcdef</Name>

<Name>abcdefg</Name>

<Name>abcdefgh</Name><GroupLevel>-1</GroupLevel><DynamicValues>

Match: 'abcdefgh'

Beware that a large number of sites generate dynamic html from several servers, not all of them behaving always identically, specially whitespace(s) (RE \s) may be appear or disappear at almost any point in the html content. I know of several sites that will deliver distinct whitespacing, even across page refresh within seconds. This can be problematic when applying a regexp on the source.

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)

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...