Raised This Month: $ Target: $400
 0% 

Regex Pattern


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-26-2014 , 07:33   Regex Pattern
Reply With Quote #1

Lately I started using Sublime Text 2 for writing AmxModX plugins, and I thought about changing PAWN highlighting Ovidius created a bit. But here is a problem with my regex pattern.
When i search with regular expression this key:
Code:
([:\w]+)\((.*\))(?!(\s*\{))
I get this result:

(text with white border is what regex found).
Now, that's all okay, i want that(I am trying to find function calls), but when i type that regular expression into .tmLanugage file(the file that mostly highlights stuff) like this:

It also highlights the function header, or NewFunction(param, otherparam) as you saw in previous picture.
Is that something related to ST2 or is that just my regex pattern? If my regex pattern is wrong, i would like some help with correcting it.
klippy is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 04-26-2014 , 12:25   Re: Regex Pattern
Reply With Quote #2

You have to ensure that there is no "{" before ")". Also, the "{" could be in a new line (as in your example).
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-26-2014 , 13:21   Re: Regex Pattern
Reply With Quote #3

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
You have to ensure that there is no "{" before ")". Also, the "{" could be in a new line (as in your example).
Why would there ever be "{" before ")"? And about that other stuff, I'm really bad at making regular expressions. That one I got is just a pattern from a site I got on while i was searching for a solution, with a little bit of my tweaking, but i can't get it to work. I would really appreciate some help.
klippy is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-26-2014 , 18:47   Re: Regex Pattern
Reply With Quote #4

If you're running it in single line mode you can't check for trailing "{", instead you'll have to check for prefixes like "public" with negative lookbehind.
__________________

Last edited by Black Rose; 04-26-2014 at 18:57.
Black Rose is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-26-2014 , 19:47   Re: Regex Pattern
Reply With Quote #5

Quote:
Originally Posted by Black Rose View Post
If you're running it in single line mode you can't check for trailing "{", instead you'll have to check for prefixes like "public" with negative lookbehind.
But what if it is just a normal function? Like this one:
PHP Code:
funcSomething(param)
{
       
server_print("Param: %d"param);

Because of this, i can't check for prefixes. I guess i will have to live with all functions(headers and function calls) being highlighted. Anyway, thank you guys for replies.

Last edited by klippy; 04-26-2014 at 19:48.
klippy is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 04-27-2014 , 00:31   Re: Regex Pattern
Reply With Quote #6

Quote:
Originally Posted by Black Rose View Post
If you're running it in single line mode you can't check for trailing "{", instead you'll have to check for prefixes like "public" with negative lookbehind.
He can add "(?:\n)*" to the pattern.

Quote:
Originally Posted by KliPPy View Post
Why would there ever be "{" before ")"? And about that other stuff, I'm really bad at making regular expressions. That one I got is just a pattern from a site I got on while i was searching for a solution, with a little bit of my tweaking, but i can't get it to work. I would really appreciate some help.
Because is the only why you can know if it's a funcion call or definition.
__________________

Last edited by Neeeeeeeeeel.-; 04-27-2014 at 00:32.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode