SA-MP Forums Archive
[Plugin] Regular expression - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] Regular expression (/showthread.php?tid=247893)

Pages: 1 2 3 4


Re: Regular expression - Blacklite - 08.05.2011

http://www.regular-expressions.info/reference.html


Re: Regular expression - Unknown123 - 09.05.2011

So its not possible to check for more latters


Re: Regular expression - Unknown123 - 09.05.2011

Isnt this right?

Copied from the link by BalckLite
Quote:

[a-zA-Z0-9] matches any letter or digit




Re: Regular expression - Unknown123 - 09.05.2011

I dont get it, i also read here

Code:
"[a-z]" Lower case letters
"[A-Z]" Upper case letters
"[0-9]" Digits
pawn Code:
#define IsValidText(%1) regex_match(%1, "[a-zA-Z0-9]")
#define IsNumber(%1) regex_match(%1, "[0-9]")



Re: Regular expression - Unknown123 - 09.05.2011

Yes, i did but i got bad english and dont understand everything what is standing there


Re: Regular expression - Wyu - 09.05.2011

You may read a tutorial first, references are typically not very good for learning if you're a beginner


Re: Regular expression - Unknown123 - 09.05.2011

Quote:

i did but i got bad english and dont understand everything what is standing there

That ^


Re: Regular expression - Wyu - 09.05.2011

Is it that hard to find another one which is written in your native language?


Re: Regular expression - Unknown123 - 09.05.2011

There is no good tutorials in my language!

wow we have soon spent a wole page on
"Did you read the page"
"Yes"
"Read a tutorial"
"i already did"

lol -.-

nvm then, ill do it on another way! because it looks like nobody want to help me


Re: Regular expression - HP - 13.05.2011

I'm new to regular expressions, but might defining the amount of letters or numbers in "regex_match" fix Unknown123's problem? I'm assuming that if there isn't defined the number or characters, the default value is 1(one), so it will check for 1 character. I'm not sure about this, but maybe this will fix it? I might actually start reading more about it, when I get back home.

pawn Code:
#define IsValidText(%1) regex_match(%1, "[a-zA-Z0-9]{1,3}") // Minimal amount of characters is 1 and maximum of all is 3
// You can also check the length of the characters separated, if you want any number or letters to be in a specific length
#define IsNumber(%1) regex_match(%1, "[0-9]{2,4}") // Minimal amount of numbers is 2 and maximum of all is 4
You can also leave the second number blank, so it well set only the minimal ammount of letters - {3, }. Just take a look at the examples brought out over here.

There is pretty much everything explained in the first post, but as I'm new to this, I don't know much about Regular Expressions. I'll learn it as soon as I have some time.


Re: Regular expression - songoku11 - 18.05.2011

Hi! Nice work!
Can you give me an example for anti advertising for sites ,ip,dns?


Re: Regular expression - Blacklite - 19.05.2011

Quote:
Originally Posted by songoku11
Посмотреть сообщение
Hi! Nice work!
Can you give me an example for anti advertising for sites ,ip,dns?
****** posted a clever regex to match web addresses earlier in this thread:

Код:
([\w-]*://)?([\w-]+\.)+([\w-]+)(/[^\s]*)*
I am aware that the link I posted earlier in this thread was a "Reference" page aimed at people who have some experienced with regex, however that same site is full of other info useful for any skill level. See the examples page here (includes a regex for IP addresses):

http://www.regular-expressions.info/examples.html

If you're completely new to regex you might want to start here:

http://www.regular-expressions.info/tutorial.html


Re: Regular expression - Burridge - 26.05.2011

I was going to post earlier, but never got around to it. Thank you very much for this plugin, it's brilliant, and has meant I've been able to recode some functions in my script, to be faster, and use a lot less code. Thank you for this.


Re: Regular expression - Gamer_Z - 08.06.2011

how did you compile this project? (ByTheWay I had to disable the precompiled headers that were enabled in your project, I do not have them?)
Код:
1>------ Rebuild All started: Project: regex, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\users\rafal\documents\visual studio 2010\projects\regex_source_2_0\sdk\amx\amx.h(60): error C2371: 'int32_t' : redefinition; different basic types
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdint.h(19) : see declaration of 'int32_t'
1>c:\users\rafal\documents\visual studio 2010\projects\regex_source_2_0\sdk\amx\amx.h(61): error C2371: 'uint32_t' : redefinition; different basic types
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdint.h(23) : see declaration of 'uint32_t'
1>  amxplugin.cpp
1>  Generating Code...
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========



Re: Regular expression - BASITJALIL - 08.06.2011

Awwww nice


Re: Regular expression - Fro1sha - 08.06.2011

Quote:
Originally Posted by gamer_Z
Посмотреть сообщение
how did you compile this project? (ByTheWay I had to disable the precompiled headers that were enabled in your project, I do not have them?)
Код:
1>------ Rebuild All started: Project: regex, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\users\rafal\documents\visual studio 2010\projects\regex_source_2_0\sdk\amx\amx.h(60): error C2371: 'int32_t' : redefinition; different basic types
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdint.h(19) : see declaration of 'int32_t'
1>c:\users\rafal\documents\visual studio 2010\projects\regex_source_2_0\sdk\amx\amx.h(61): error C2371: 'uint32_t' : redefinition; different basic types
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdint.h(23) : see declaration of 'uint32_t'
1>  amxplugin.cpp
1>  Generating Code...
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
I don't know how to fix it in VS10. Use VS9 =)


Re: Regular expression - Gamer_Z - 08.06.2011

I hope I can use vs9 side by side with vs10 (?)


Re: Regular expression - Fro1sha - 08.06.2011

Quote:
Originally Posted by gamer_Z
Посмотреть сообщение
I hope I can use vs9 side by side with vs10 (?)
Yes =)


Re: Regular expression - Gamer_Z - 08.06.2011

Okay it works, thanks for the solution
Now I can try to make my StringReplace (and maybe a stringLibrary) plugin
Actually I have one plugin but it is slower than pawn str_replace xD


Re: Regular expression - BaubaS - 08.06.2011

#define IsValidRpName(%1) \
regex_match(%1, "([A-Z]{1,1})[a-z]{2,9}+_([A-Z]{1,1})[a-z]{2,9}")


Would check only for _ or letters too?

I mean:

TesT_TeST would return 1 or 0?