Hobione's Weblog

Living & Breathing in Web 2.0 Era

Java regular expression, replace slashes

In my ui I had this line:

<f:param name="fullPath" value="#{model.folderObject.folder.fullPath}"/>

So, fullPath contains “\Electronic Project Folders\AJW-148\AMASS-2005-000181-A\CIF Replacement 234-2005X546A\CCA, AMASS CIM”
I needed to replace singe slash with double slashes

FacesContext context = FacesContext.getCurrentInstance();
Map<String, String> params = context.getExternalContext().getRequestParameterMap();
String fullPath = URLDecoder.decode(params.get("fullPath"));
String fullPath2 = fullPath.replaceAll("\\\\", "\\\\" );

Thanks to Jason Lee.

Advertisements

June 9, 2008 - Posted by | Java core

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: