java - Change all non-alphanumerics to a + -


I am currently in a pickle.

I have a text box that the user enters is an address, which is then sent as part of a URL.

Currently, I have solved a word well - say "Brighton". But, if the user wants to add more details in the query - say, a street address, I go into problems.

32 Sydney Street, Brighton, The City of Brighton and Hove BN1 NEP, UK

What would be the best way to change it - I suppose That's a Reazx can do this, but I have always fought with them.

32 + Sydney + Street + Brighton + + + + Brighton + + + + + + + + + + + + + + + + + + + + + + + 4EP + City + UK + I'm currently doing this - which I think is messy, and okay, not just good programming if I add conditional to '++'

  string [] strArray = str.split ("") , Then gross would be more gross; Int strSize = strArray.length; // puts the split array back together, and adds a plus between str = ""; For (int i = 0; i  

By all means, I am thinking of running two ++ (which can cancel the URL) in one line, or actually run the risk of having a 'gross' code.

Thank you for your time

Oli, it should do this:

  try {string result string = topic string.replaceless ("(? I) [^ a-z0- 9] +", "+"); } Hold (syntax error in the regular expression) Holding (syntax error in regular expression) {// prefix illegal illegal usage} {// Syntax error in replacement text (unchanged $ sign?)} Hold (pre-indexed express exchanges) {// non existent Backforgance used replacement text}  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -