Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
About
Team
Rules
Stats
Status
Sitemap
Chat
Downloads
Forum
News
Our Projects
Major Community Projects
Recent Posts
Unread Posts
Replies
Tools
SourceCoder3
Other Things...
Omnimaga Radio
TI-83 Plus ASM File Unsquisher
Z80 Conversion Tools
IES TI File Editor
Free RAM areas
Comprehensive Getkeyr table
URL Shortener
Online Axe Tilemap Editor
Help
Contact Us
Change Request
Report Issue/Bug
Team
Articles
Members
View the memberlist
Search For Members
Buddies
Login
Register
Omnimaga
»
Forum
»
General Discussion
»
Technology and Development
»
Computer Programming
»
Regex (regular expressions)
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: Regex (regular expressions) (Read 6168 times)
0 Members and 1 Guest are viewing this topic.
BlakPilar
LV8
Addict (Next: 1000)
Posts: 734
Rating: +44/-1
Regex (regular expressions)
«
on:
October 23, 2011, 02:19:00 pm »
Does anyone know regex well? I need to be able to select everything between a double quote and either another double quote, the end of a line, or a two character sequence ("->" for example). What I have now kind of works, except the highlighting only stops after the '>' and sometimes it selects everything for a while after the '>'.
Here's what it is now: (by the way, for the '->' part, I completely guessed lol)
Code:
[Select]
@"""[^>]+""|""[^>]+|""[^>]+'->'"
Logged
Michael_Lee
LV9
Veteran (Next: 1337)
Posts: 1019
Rating: +124/-9
Re: Regex (regular expressions)
«
Reply #1 on:
October 23, 2011, 03:31:09 pm »
Try this?
Code:
[Select]
\"(.+?)(\"|$|->)
I tested it here:
http://regexpal.com/
but I'm not certain if there are any syntax differences between that and C# (which is what I think you're using?)
If you want only what's between the quotation marks/->/newline, capture only the
first matching group
(see the first answer).
«
Last Edit: October 23, 2011, 03:40:23 pm by Michael_Lee
»
Logged
My website: Currently boring.
Projects:
Axe Interpreter
> Core: Done
> Memory: Need write code to add constants.
> Graphics: Rewritten. Needs to integrate sprites with constants.
> IO: GetKey done. Need to add mostly homescreen IO stuff.
Croquette
:
> Stomping bugs
> Internet version: On hold until I can make my website less boring/broken.
BlakPilar
LV8
Addict (Next: 1000)
Posts: 734
Rating: +44/-1
Re: Regex (regular expressions)
«
Reply #2 on:
October 23, 2011, 03:39:52 pm »
Ahh, yes, that works. The only thing is it highlights '->' too... Oh well, good enough for now! Thank you!
Logged
Michael_Lee
LV9
Veteran (Next: 1337)
Posts: 1019
Rating: +124/-9
Re: Regex (regular expressions)
«
Reply #3 on:
October 23, 2011, 03:41:24 pm »
No problem.
Have you tried looking at the stackoverflow link and tried capturing the first matching group instead of capturing the entire regex? That might solve the highlighted '->' problem.
«
Last Edit: October 23, 2011, 03:41:45 pm by Michael_Lee
»
Logged
My website: Currently boring.
Projects:
Axe Interpreter
> Core: Done
> Memory: Need write code to add constants.
> Graphics: Rewritten. Needs to integrate sprites with constants.
> IO: GetKey done. Need to add mostly homescreen IO stuff.
Croquette
:
> Stomping bugs
> Internet version: On hold until I can make my website less boring/broken.
BlakPilar
LV8
Addict (Next: 1000)
Posts: 734
Rating: +44/-1
Re: Regex (regular expressions)
«
Reply #4 on:
October 23, 2011, 03:51:12 pm »
Oops, didn't see that part lol. I'll look at it and see what I can do, thanks again.
Logged
C0deH4cker
LV5
Advanced (Next: 300)
Posts: 258
Rating: +11/-1
Re: Regex (regular expressions)
«
Reply #5 on:
October 23, 2011, 04:54:00 pm »
can anyone point me to a really good regex tutorial that you KNOW is good?
Logged
Deep Toaster
So much to do, so much time, so little motivation
Administrator
LV13
Extreme Addict (Next: 9001)
Posts: 8217
Rating: +758/-15
Re: Regex (regular expressions)
«
Reply #6 on:
October 23, 2011, 04:54:59 pm »
http://regular-expressions.info/
Everything is there, complete with examples.
Logged
+2/-0 karm for this message
C0deH4cker
LV5
Advanced (Next: 300)
Posts: 258
Rating: +11/-1
Re: Regex (regular expressions)
«
Reply #7 on:
October 23, 2011, 04:57:03 pm »
alright, thanks! +1
Logged
BlakPilar
LV8
Addict (Next: 1000)
Posts: 734
Rating: +44/-1
Re: Regex (regular expressions)
«
Reply #8 on:
April 05, 2012, 12:00:44 pm »
So, I have another regex question... I looked at the tutorial and reference guide, but I can't seem to find out how to do what I want.
I want to be able to match everything between two single quotes ('...') but only if there is a single character between them, or a backslash then another character. Basically, C-style character declarations. This is what I have right now:
\'.+?\'
. It doesn't capture
''
which is what I wanted, but it captures anything that contains one or more character between the single quotes (I know it's because of the +'s "rule"). I mean, I suppose I could do something like
\'[a-zA-Z0-9 _\?!@#$%^&\*\(\)\[\]]\'
but that would be cheating and wouldn't capture everything...
«
Last Edit: April 05, 2012, 12:01:17 pm by BlakPilar
»
Logged
cooliojazz
Support Staff
LV7
Elite (Next: 700)
Posts: 619
Rating: +66/-9
I omnoms on your soul
Re: Regex (regular expressions)
«
Reply #9 on:
April 05, 2012, 04:47:05 pm »
How about /'([^\\]|\\.)'/ does that do what you want?
«
Last Edit: April 05, 2012, 04:47:17 pm by cooliojazz
»
Logged
+1/-0 karm for this message
Spoiler
For
Random signess
:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."
TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here
|
The Rest Should Be Here (Bandcamp)
BlakPilar
LV8
Addict (Next: 1000)
Posts: 734
Rating: +44/-1
Re: Regex (regular expressions)
«
Reply #10 on:
April 05, 2012, 05:58:12 pm »
I'm using C# (so .NET) and I had to change that to
\'([^\\]|\\.)\'
, but it says there's an unterminated [] pair, which is weird... I tried changing it to
\'(.|\\.)\'
(I don't understand the need for a character class
). My test search string is
'gh' ' ' 'j' ';' ' fsdf' ''
and when I did the changed version my result was
' ', ' ', ' ', ' '
EDIT: Wow, nevermind... I added an @ before the edited regex thing and changed my string so there were commas between the character examples and it worked fine. Thank you!
«
Last Edit: April 05, 2012, 06:03:42 pm by BlakPilar
»
Logged
cooliojazz
Support Staff
LV7
Elite (Next: 700)
Posts: 619
Rating: +66/-9
I omnoms on your soul
Re: Regex (regular expressions)
«
Reply #11 on:
April 05, 2012, 06:16:36 pm »
The character class is so it will capture \ characters, without it, it will return just \ if you say have '\a' instead of what it should, which is \a. The problem is that you probably didn't re-escape everything... =P if you wanted to actually put it in a string it would need to be "\'([^\\\\]|\\\\.)\'". (Do you really need to escape single quotes in strings defined with double quotes?)
EDIT, also I'm curious, what does the @ do?
«
Last Edit: April 05, 2012, 06:20:13 pm by cooliojazz
»
Logged
Spoiler
For
Random signess
:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."
TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here
|
The Rest Should Be Here (Bandcamp)
Print
Pages: [
1
]
Go Up
« previous
next »
Omnimaga
»
Forum
»
General Discussion
»
Technology and Development
»
Computer Programming
»
Regex (regular expressions)