0

I'm developing an android app, I need to construct an url form some strings in an Ad object.

So, the header has to be converted into a correct url string, in Codeigniter I have the function called:

url_title($str, $separator = '-', $lowercase = FALSE)

But how I do this in android?

My actual string:

"https://www.bachecubano.com" + category + "/" + my_custom_function(header) + "/" + ad_id;

where my_custom_function(header) is the desired function which removes spaces, remove special characters, etc.

The query = URLEncoder.encode(text, "utf-8"); answer won't solve my problem, it change space for +, I need spaces changed to -

Actual string:

https://www.bachecubano.com/celulares/QUEREMOS+Q+TENGA+UN+BUEN+TELEFONO+Y+LO+ADQUIERA+MAS+BARATO/674337

Desired String:

https://www.bachecubano.com/celulares/QUEREMOS-Q-TENGA-UN-BUEN-TELEFONO-Y-LO-ADQUIERA-MAS-BARATO/674337

In other words, I need this in Java (PHP function)

return preg_replace('/[^a-zA-Z0-9]+/', ' ', $string);
Erich García
  • 1,648
  • 21
  • 30

0 Answers0