repeticiones en string

30/09/2004 - 02:06 por nino | Informe spam
si tengo:

dim x as string = "Pepe Juan Pedro Pepe Maxi"


cómo puedo preguntar cuántas veces se repite Pepe en el
string??

en este caso el resultado sería dos.



gracias

Preguntas similare

Leer las respuestas

#1 Luis Miguel Cisneros L.
30/09/2004 - 03:54 | Informe spam
Hola!

Usa Expresiones Regulares y el objeto MatcCollection:

aqui tienes un ejemplo:
Dim s As String = "Luis Miguel Luis Antonio Pepe luis LUIS"
Dim mc As System.Text.RegularExpressions.MatchCollection
mc = System.Text.RegularExpressions.Regex.Matches(s, "Luis")
MsgBox(mc.Count)
mc = System.Text.RegularExpressions.Regex.Matches(s, "Luis",
System.Text.RegularExpressions.RegexOptions.IgnoreCase)
MsgBox(mc.Count)


Saludos
Luis Cisneros
"nino" wrote in message
news:1c9501c4a681$574b6f50$
si tengo:

dim x as string = "Pepe Juan Pedro Pepe Maxi"


cómo puedo preguntar cuántas veces se repite Pepe en el
string??

en este caso el resultado sería dos.



gracias
Respuesta Responder a este mensaje
#2 Jorge R
30/09/2004 - 22:31 | Informe spam
Dim x As String = "Pepe Juan Pedro Pepe Maxi"

Dim vctDatos() As String

vctDatos = Split(x, "Pepe")

MsgBox(vctDatos.Length)



"nino" escribió en el mensaje
news:1c9501c4a681$574b6f50$
si tengo:

dim x as string = "Pepe Juan Pedro Pepe Maxi"


cómo puedo preguntar cuántas veces se repite Pepe en el
string??

en este caso el resultado sería dos.



gracias
Respuesta Responder a este mensaje
#3 Pedro Luna Montalvo, MVP
03/10/2004 - 05:17 | Informe spam
En realidad, deberia ser vctDatos.Length - 1.
Saludos,
Pedro Luna, MVP
Gye, Ecu

"Jorge R" escribió en el mensaje
news:%
Dim x As String = "Pepe Juan Pedro Pepe Maxi"

Dim vctDatos() As String

vctDatos = Split(x, "Pepe")

MsgBox(vctDatos.Length)



"nino" escribió en el mensaje
news:1c9501c4a681$574b6f50$
si tengo:

dim x as string = "Pepe Juan Pedro Pepe Maxi"


cómo puedo preguntar cuántas veces se repite Pepe en el
string??

en este caso el resultado sería dos.



gracias


email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida