AutoHotkey Community

It is currently May 27th, 2012, 4:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: February 24th, 2010, 1:48 pm 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
Code:
vfv(n) { ; vfv(n) : n - Name of function or variable : true if valid else false
   Return !RegExMatch(n, "^[^#$0-9@-\[\]_a-z€-ÿ]{1,253}$")
}


Usage:

[code]s := "#$0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]_abcdefghijklmnopqrstuvwxyz€

_________________
Religion is false. >_>


Last edited by trik on February 25th, 2010, 2:32 pm, edited 10 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 2:09 pm 
good to have. I may use that at my project. But i do not like the name of the function. I prefer more "isValidName()".

At home i take a more detail look at this.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 2:11 pm 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
Tuncay n-l-i mobile wrote:
But i do not like the name of the function. I prefer more "isValidName()".


You are more than welcome to change the function name to whatever you wish, but I prefer ValidFunctionOrVariable(Name). I shortened to vfv(n).

_________________
Religion is false. >_>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 4:32 pm 
Code:
 vfv(n) { ; vfv(n) : n - Name of function or variable : true if valid else false
   Return !RegExMatch(n, "[^#0-\[\]-ÿ]{1,253}") ; Would it be faster without the logical-not and circumflex?
}

msgbox % vfv( "ya;:as" ) ? "YES" : "NO"


fails.

try using more precise needles such as \x30-\x39 and such

greets
dR


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 4:38 pm 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
dR* wrote:
Code:
 vfv(n) { ; vfv(n) : n - Name of function or variable : true if valid else false
   Return !RegExMatch(n, "[^#0-\[\]-ÿ]{1,253}") ; Would it be faster without the logical-not and circumflex?
}

msgbox % vfv( "ya;:as" ) ? "YES" : "NO"


fails.

try using more precise needles such as \x30-\x39 and such

greets
dR


I thought I cut those characters out while I was making the RegEx.. I will fix it in a few minutes.


Edit: Updated function to the following:

Code:
vfv(n) { ; vfv(n) : n - Name of function or variable : true if valid else false
   Return !RegExMatch(n, "[^#0-9@-\[\]-ÿ]{1,253}")
}

_________________
Religion is false. >_>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 5:28 pm 
still fails
Code:
msgbox % vfv( "y{es}no" ) ? "YES" : "NO"


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 5:45 pm 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
Code:
35 48 49 50 51 52 53 54 55 56 57 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 93 95 97 98 99
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 128 129 130 131 132 133 134 135 136 137
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 161 162 163 164 165 166 167 168 169 170 171
172 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255


That is what I sift through to find bad ranges. I hope you can understand why I keep missing some. :lol:

Updated the code to:

Code:
vfv(n) { ; vfv(n) : n - Name of function or variable : true if valid else false
   Return !RegExMatch(n, "[^#0-9@-\[\]_a-z€-Ÿ¡-¬®-ÿ]{1,253}")
   ; Hex needle: [^\x23\x30-\x39\x40-\x5b\x5d\x5f\x61-\x7a\x80-\x9f\xa1-\xac\xae-\xff]{1,253}
}

_________________
Religion is false. >_>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 6:17 pm 
Code:
msgbox % vfv( "$YEAH" ) ? "YES" : "NO"


fail


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 6:18 pm 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
dr* wrote:
Code:
msgbox % vfv( "$YEAH" ) ? "YES" : "NO"


fail


>_>

Code:
vfv(n) { ; vfv(n) : n - Name of function or variable : true if valid else false
   Return !RegExMatch(n, "[^#$0-9@-\[\]_a-z€-Ÿ¡-¬®-ÿ]{1,253}")
   ; Hex needle: [^\x23\x24\x30-\x39\x40-\x5b\x5d\x5f\x61-\x7a\x80-\x9f\xa1-\xac\xae-\xff]{1,253}
}

_________________
Religion is false. >_>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 6:18 pm 
ANSI Table
http://www.mmvisual.de/Hilfe/BinTerm/T044.htm


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 6:23 pm 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
dR* wrote:


An ANSI table does not know which characters AutoHotkey does or does not allow into its functions and variables.

_________________
Religion is false. >_>


Report this post
Top
 Profile  
Reply with quote  
 Post subject: HORIZ SCROLLING SUCKS
PostPosted: February 24th, 2010, 6:25 pm 
OMG...I now have a widescreen monitor & this thread STILL gives me horiz scrolling!...aaaahhhh!


Report this post
Top
  
Reply with quote  
PostPosted: February 24th, 2010, 6:26 pm 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
Anonymous wrote:
OMG...I now have a widescreen monitor & this thread STILL gives me horiz scrolling!...aaaahhhh!


I would break the lines, but then the function in the example would not work. Anyway, it looks just fine to me in 1024x1280 and 768x1366.

_________________
Religion is false. >_>


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 24th, 2010, 6:59 pm 
trik wrote:
I would break the lines...

...a really simple solution is to add about 5 lines (comment lines or blank lines) to the code so it auto-collapses...(a better solution requires me editing the sites code.js)...

trik wrote:
Anyway, it looks just fine to me...

...that's not possible...

trik wrote:
...in 1024x1280 and 768x1366.

...did you swap the numbers?...or is your monitor really in portrait?...(which would make you have more horiz scrolling)? Mine is 1280x720 & has horiz scrolling (1280 is horiz/x, 720 is vertical/y)...


Report this post
Top
  
Reply with quote  
PostPosted: February 24th, 2010, 7:01 pm 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
Anonymous wrote:
...did you swap the numbers?...or is your monitor really in portrait?...(which would make you have more horiz scrolling)? Mine is 1280x720 & has horiz scrolling (1280 is horiz/x, 720 is vertical/y)...


:shock: Whoops. :oops: I did swap them, yes.

_________________
Religion is false. >_>


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group