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 | Leave a comment