Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/05/2007, 02:21
tammander
 
Fecha de Ingreso: enero-2006
Ubicación: Torroles (Costa der Só)
Mensajes: 1.017
Antigüedad: 19 años, 3 meses
Puntos: 7
Re: Tratar cadenas

Yo uso esta clase

Código:
class clsRegExp
    private obj, pattern, gg, ic
    
    property let setPattern(str)
        pattern = str
    end property

    property let setGlobal(str)
        gg = str
    end property

    property let setIgnoreCase(str)
        ic = str
    end property

    property get strPattern
        strPattern = pattern
    end property

  '*********************************************************************
  ' Initialization/Termination            BOF
  '*********************************************************************

  'Initialize Class Members
  Private Sub Class_Initialize()
    pattern = ""
    gg = true
    ic = false
  End Sub

  'Terminate and unload all created objects
  Private Sub Class_Terminate()
    ' Terminate 
  End Sub
  '*********************************************************************
  ' Initialization/Termination            EOF
  '*********************************************************************

  
  public function isValidData(esto)
      dim obj, found
        set obj = New RegExp 
        with obj
             .Pattern = pattern
             .Global = gg
             .IgnoreCase = ic
        end with
        isValidData = obj.test(esto)
        set obj = nothing
  end function

  public function substract(esto)
      dim obj, found
        set obj = New RegExp 
        with obj
             .Pattern = pattern
             .Global = gg
             .IgnoreCase = ic
        end with
        Set Matches = obj.Execute(esto)
        found = ""
        for each m in Matches
            found = found & m.value
        next
        substract = found
        set obj = nothing
  end function
  
end class
Para usarla, te dejo un ejemplo:

b = "4'32#frffwDDF-;"
set r = new clsRegExp
r.setPattern = "\w"
response.Write("<br>" & r.substract(b))
set r = nothing


espero te sirva


Un saludo
__________________
"Tus pecados son el estiércol sobre el que florecerán las flores de tus virtudes" - Gerald Messadié -