Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > replacement

Reply
Thread Tools

replacement

 
 
sara
Guest
Posts: n/a
 
      12-14-2006
Hi All,

I have a file for which each line has a substring monthday
13041140 Jun28 gh
130164140 Jun29 ad
130114540 Jun30 gg
1301140 Aug6 fty
1301140 Aug4 yy
.....

I want to convert "monthDay" part into "month-day" format, so that the
last line will become
1301140 Aug-4 yy

I know that there are lots of way of doing this but do you know how can
I do this using replaceall function?

Thanks a lot.

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Tobias_Schr=F6er?=
Guest
Posts: n/a
 
      12-14-2006
Hi,

sara schrieb:
> Hi All,
>
> I have a file for which each line has a substring monthday
> 13041140 Jun28 gh
> 130164140 Jun29 ad
> 130114540 Jun30 gg
> 1301140 Aug6 fty
> 1301140 Aug4 yy
> ....
>
> I want to convert "monthDay" part into "month-day" format, so that the
> last line will become
> 1301140 Aug-4 yy
>
> I know that there are lots of way of doing this but do you know how can
> I do this using replaceall function?


I'd suggest that you have to use regular expressions. String#replaceAll
takes a regEx, too, but replaces the matches and does no insertions.

With regEx create two groups of each line, one with the characters left
of the '-', the other with the characters right of the '-'. Then create
your new string. Your regEx pattern would be something like

([0-9]* [a-zA-Z]{3})([0-9]{1,2}.*\r\n)


HTH,
Tobi
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacement PSU for an ADSL Router Edward W. Thompson Wireless Networking 0 09-06-2005 10:40 AM
Replacement for FF calendar extension Dan Firefox 5 03-23-2005 08:38 PM
Replacement for AOL newsgroup access EJGroth Firefox 0 02-08-2005 02:41 PM
Calendar replacement William W. Plummer Firefox 1 07-02-2004 04:10 PM
Replacement For Access Point KS Wireless Networking 1 06-24-2004 04:40 AM



Advertisments