Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

Help : Breaking the string

Thread view: 
Pradeep - 25 May 2006 07:12 GMT
Hi,
Can anyone help in breaking a lengthy string..
The scenario is..
1. It should break by 15 char using "-" at the 15th char.
2. Whenever it encounters URL, it should break without "-"
3. While breaking it should not afftect the tags..
4. When parsing we should not consider the length of tags.
I'll give some examples so that it will be easy to understand.

Example 1:
Input : thisisalengthywordtobebrokenintostrings
Output:
thisisalengthy-
wordtobebroken-
intostrings

Example 2:
Input: this is a lengthy word to be broken into strings
Output:
this is a
lengthy word to
be broken into
strings

Example 3:
Input: this is a lengthy word to be brokenintostrings1234567890
Output:
this is a
lengthy word to
be brokenintos-
trings12345678-
90

Example 4:
Input: this is url http://www.exampleurltobebroken.com/tryit
Output:
this is url
http://www.exam
pleurltobebroke
n.com/tryit

Example 5:
Input: input with tags <b>hi helloworldexample</b>
Output:
input with tags
<b>hi helloworlde-
xample</b>

It will be much helpful if you provide sample code..

Thanks in Advance..

Regards,
Pradeep.
Jeroen V. - 25 May 2006 08:56 GMT
> Hi,
> Can anyone help in breaking a lengthy string..
[quoted text clipped - 4 lines]
> 4. When parsing we should not consider the length of tags.
> I'll give some examples so that it will be easy to understand.

General approach: calculate all intervals [startPos, endPos] you don't
want to split (use regices (isn't this the plural of regex? :-/)). Then
start splitting.

(rule 4 is unclear to me)
Lasse Reichstein Nielsen - 25 May 2006 13:50 GMT
> (use regices (isn't this the plural of regex?  :-/)).

Since regex (or regexp) is short for "regular expression", the more
likely plural would be regexes or regexps.

/L
Signature

Lasse Reichstein Nielsen  -  lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
 'Faith without judgement merely degrades the spirit divine.'

Oliver Wong - 25 May 2006 16:35 GMT
>> Hi,
>> Can anyone help in breaking a lengthy string..
[quoted text clipped - 4 lines]
>> 4. When parsing we should not consider the length of tags.
>> I'll give some examples so that it will be easy to understand.

> (rule 4 is unclear to me)

   Given the examples, it sounds like the OP is hyphenating HTML data. He
doesn't want to break (in the sense of render-useless) the URLs, nor the
tags like <b>foo</b>, but for whatever reason, he's not happy with the word
wrapping that's currently done by his user agent.

   Incidently, although it's never mentioned in his rules, he DOES want
word wrapping to be done in preference to hyphenating, when possible. So
newlines would have to be inserted as well.

   - Oliver
Thomas Schodt - 25 May 2006 09:24 GMT
> Hi,
> Can anyone help in breaking a lengthy string.
>
> ...
>
> It will be much helpful if you provide sample code..

This is quite trivial,
the kind of post one expects to find in clj.help

Anyway, is this homework,
or did you take on a task that exceeds your abilities?

Have you made a start?
Oliver Wong - 25 May 2006 16:33 GMT
> Hi,
> Can anyone help in breaking a lengthy string..

   Crosspost, don't multipost:
http://www.cs.tut.fi/~jkorpela/usenet/xpost.html

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.