Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1.  
  2. Public Function ObtenerCaracteresPermitidos(ByVal descripcionTexto As String) As String
  3. 'Valida Caracteres para el texto del aviso y codigo identificador
  4. Dim strError As String = ""
  5. Dim resultado As String = ""
  6. Dim caracteresPermitidos As String = objDatos.ObtenerCaracteresPermitidos()
  7. Dim rgx As New Regex(caracteresPermitidos, RegexOptions.IgnoreCase)
  8. Dim matches As MatchCollection = rgx.Matches(descripcionTexto)
  9.  
  10. Dim largoTexto As Int32 = descripcionTexto.ToString().Length
  11. Dim largoCoincidencias As Int32 = rgx.Matches(descripcionTexto).Count
  12. Dim cantidadInvalido As String = (largoTexto - largoCoincidencias).ToString()
  13. ' resultado = rgx.Replace(descripcionTexto, "*")
  14. resultado = rgx.Replace(resultado, " ")
  15. If largoTexto <> largoCoincidencias Then
  16. strError = "Total de caracteres no permitidos : " + cantidadInvalido + " Carateres: " + resultado
  17. End If
  18. Return strError
  19. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement