Hi,

the following is slightly better (not being picky, huh tidy :tongue:) because it will immediately halt your script when it matched a space before or after the comma, where in tidy's script it will keep processing, until all commas were found. Also i use var %y = $ifmatch, so that your script doesnt need to look up the position again, it's stored in a variable, which is also slighly faster. Either way works though

Code:
var %x = 1, %y
while $pos($1-,$chr(44),%x) {
 %y = $ifmatch
  if $mid($1-,$calc(%y -1),1) == $chr(32) || $mid($1-,$calc(%y +1),1) == $chr(32) { return }
  inc %x
}
commands  

You could make a custom identifier like this:
Code:
 
alias chk.comma {
  var %x = 1, %y
  while $pos($1-,$chr(44),%x) {
    %y = $ifmatch
    if $mid($1-,$calc(%y -1),1) == $chr(32) || $mid($1-,$calc(%y +1),1) == $chr(32) { return true }
    inc %x
  }
} 

Then simply use this in your script:
Code:
 
if !$chk.comma($1-) { do stuff } 


Although I'm positive that a well written $regex is surely faster, though I'm not familiar enough with em to make a decent one.


Edit:
Code:

alias chk.comma var %re = /(\s*\,\s+|\s+\,\s*)/ | if $regex($1-,%re) { return true }  


Hehe, it worx, but well, im sure it can be optimized a lot.

Enjoy

Last edited by FiberOPtics; 25/04/04 06:37 PM.