Solved

Change String by pattern

Posted on 2009-05-04
2
170 Views
Last Modified: 2012-05-06
Hi.
Have a preatty easy question. I need the simplest way to do this:

I have Strings like: 12399, 12500, 12204, 1208, 07
I need them to be like this: "123/ 99", "123/ 00", 122/ 04", "12/ 08", "/ 07"

Please note that the last two is valid.
The pattern is "xxxx/ yy" where yy is mandatory.

Any ideas?
0
Comment
Question by:kristian_gr
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
Comment Utility
Try
s = s.replaceAll("(\\d*)(\\d{2})", "$1/$2");

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:-)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Basics of Drool Rule Engine with few samples 2 39
array220 challenge 8 45
nestparen challenge 4 55
JDeveloper 12c for 32 bit 4 34
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now