I have this input from the user:
*. *. *. *
(* = sensor) This string is an input from the user, this is the user who wants to censor. How do I change it in regex? EDIT: Let me explain again. The user wants to censor anything between dots *, so he is *. *. *. *.
I have tried to do this:
< Code> string string = "93.38.31.43 and 39.53.19.33 and lala.laala.laala.laala"; String input = "*. *. *. *"; String instead of word = "[sensor]"; Input = input.replaceAll ("\\ *", "\\\\\ w +"); Strline = strline.replaceAll ("(? = \\ s +) \\ S *)" + input + "(? = \\ s +) \\ S *", replaceWord); I tried to replace * with * to get this output: belongs to the IP [sensor] and [sensor] and [Sensor]
But it does not work, nothing changes.
When I do this, it works:
StrLine = strline.replaceAll ("? & Lt; = \\ s +) \\ S *" + "\\ w + \\. \ W + \\. \\ w + \\. \\ w \" + "(? \ R +) \\ s *", replaceWord);
Why does not this work? Is there a better way to do this?
You can use it:
string string = " 93.38.31.43 and 39.53.19.33 and Lala.Lala.Lala.Lala "; String input = "*. *. *. *"; String instead of word = "[sensor]"; Input = input.replace ("*", "\\ w +"). replace the (".", "\\."); Println (input); // \ w + \. \ W + \. \ W + \. W + strline = strline.replaceAll ("\\ b" + input + "\\ b", replace); Println (strLine); // = & gt; [Sensors] and [sensors] and [sensors]
No comments:
Post a Comment