Bonjour,
Voilà j'ai un pb. Je cherc5.
he à trouver une chaine de début et une chaine de fin.
Et récupérer celle du milieu.
Ma fonction est la suivante:
Alors quand je mets 123456789 et que ma fonction est
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 public string AttrappeChaineEntre(string orig, string debut, string fin) { string pattern = string.Format("({0})(.*?)({1})", debut, fin); Regex regex = new Regex(pattern); if(regex.IsMatch(orig.ToString())) { MessageBox.Show(regex.Replace(orig, "$2")); //return regex.Replace(orig, "$2"); } return regex; }
string AttrappeChaineEntre("123456789", "123", "789") ;
Il m'affiche 456.
Mais si je mets:
string AttrappeChaineEntre("12345678912355555789", "123", "789") ;
Il m'affiche 45655555.
Hors j'aimerais pouvoir récupérer 456
Puis dans une autre chaine 55555
Je pensais l'insérer dans un arrayList et la retourner mais je vois pas comment faire.
Vous savez comment je pourrais faire?
Merci
Partager