Bonjour ;
Je cherche une fonction qui reçoit un texte et un mot en entré et retourne une phrase en sortie ;
Dans cette fonction on cherche un mot donnée dans le texte puis retourne la phrase qui suit ce mot jusqu’au retour à la ligne.

Exemple : si le texte est comme suit :

PORT : 30000 -> CAID: 0500 CSAT (19E) Viaccess
PORT : 30001 -> CAID: 0500 CSAT (19E) Seca
PORT : 30002 -> CAID: 0500 CSAT (19E) Provider 022610
PORT : 30003 -> CAID: 0500 JSC Sports (13E/7W)
PORT : 30004 -> CAID: 0500 BiSS TV (13E/5W/19E)
PORT : 30005 -> CAID: 0500 SRG Swiss (13E)
PORT : 30006 -> CAID: 0500 Canal+ Marghreb (26E)
PORT : 30007 -> CAID: 0D08 AlMajd (30E/26E)
PORT : 30008 -> CAID: 0622 Canal+ NL (19E)
PORT : 30009 -> CAID: 0500 ART/JSC (7W) Provider 041500
PORT : 30010 -> CAID: 0604 ART//Nova
PORT : 30011 -> CAID: 093B SKY Italia (13E)
PORT : 30012 -> CAID: 1702 SKY Deutschland (19E)
PORT : 30013 -> CAID: 0100 Digital+ (19E) Seca
PORT : 30014 -> CAID: 0100 Cyfra+ (13E
PORT : 30015 -> CAID: 1810 Digital+ HD (30W/19E)
PORT : 30016 -> CAID: 0963 SKY UK (28E)
PORT : 30017 -> CAID: 1803 Polsat HD (13E)

Si le mot demandé =”30005” la fonction doit retourner la phrase ” -> CAID: 0500 SRG Swiss (13E)”

Voici mon code
J’ai converti le texte et le mot recherché en tableaux de type caractère char[]text et char[]mot
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
19
20
21
22
23
24
25
26
27
28
29
 
 
private String get(char[]text, char[]mot) {
		    int nb = 0;                               
		    boolean tr= false;
		    int lengthtxt= text.length;
		    int lengthmot= mot.length;
		    String phrase="";
		    int i =0;
                              // en cherche le mot dans le text
		    while (i<lengthtxt && tr == false){
		              if (mot[nb] == text[i]){
		            	  nb++;
		            	  if(nb==lengthmot){
		            		  tr=true;
		            	  }
		              }
		              i++;		                               
		     }
                              // Si le mot existe dans le text
		    if (tr){
		    	// en cherche la phrase qui suit le mot jusqu'au retour chariot 
		    	while (i<lengthtxt && text[i] != RC){
		    		phrase=phrase+text[i];
		    		i++;
		    	}
		    }
                return phrase;
		}
Mon problème est dans le variable RC qui signifié le retour chariot ; Je n’ai pas trouvé comment tester le retour chariot en java.