flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Regular expresions

Author
Thread Post new topic Reply to topic
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
I have a text where I want to find Coordinate, Time, Time
The text is: RANDOM TEXT, Coordinate, RANDOM TEXT, Time, RANDOM TEXT, Time, RANDOM TEXT.....

These are the expresions I want to match
Code:
(\([-+]?\d*\|[-+]?\d*\))
random text
(\d*\:\d*\:\d*)
random text
(\d*\:\d*\:\d*)
random text
    

If I do this:
Code:
(\([-+]?\d*\|[-+]?\d*\))
(.+?)
(\d*\:\d*\:\d*)
(.+?)
(\d*\:\d*\:\d*)
    

The expression works, but the random text is included in the result.

What I want is to exclude the random text from the result.
So the result is COORDINATES, TIME, TIME


Any Idea?

Thanks in advance
Post 10 Jun 2012, 18:53
View user's profile Send private message Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
I´m really a noob at regular expresions. But I managed to solve the problem.

The () operator is used to group a pattern. So the solution is to use .+? in the middle without the grouping.
Code:
(\([-+]?\d*\|[-+]?\d*\)) 
.+? 
(\d*\:\d*\:\d*) 
.+? 
(\d*\:\d*\:\d*)
    
Post 10 Jun 2012, 22:49
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.