/    Sign up×
Community /Pin to ProfileBookmark

parsing a text

i have a text written in a textarea like this for example :
—>textarea
1)dfgsdfg
dsfgsdg345234523453245 3245 wdrg wert342 65
sdfgdsfg sdfgewrt rewtert 2)dfg ertwer we
rtwe52345erwtgfsdgq34rt
—>end of textarea

i want to parse this text so it will be disslayed in rows like this (after i read it from the DB and write it for example to a hidden <DIV>:
1)dfgsdfg dsfgsdg345234523453245 3245 wdrg wert342 65 sdfgdsfg fgewrt rewtert
2)dfg ertwer we rtwe52345erwtgfsdgq34rt

thnaks i nadvance
peleg

to post a comment
JavaScript

13 Comments(s)

Copy linkTweet thisAlerts:
@PittimannMar 03.2005 — Hi!

What language are you using for your DB stuff? It will depend on that, how to achieve what you want.

The basic thing is, either to replace the line breaks in the textarea's value with <br>'s before writing the stuff into the DB or when you retrieve it from the DB.

Cheers - Pit
Copy linkTweet thisAlerts:
@pelegk1authorMar 03.2005 — beacuse it dosent handle with the => 2)

which i gave in the text i wrote
Copy linkTweet thisAlerts:
@PittimannMar 03.2005 — [i]Originally posted by pelegk1 [/i]

[B]beacuse it dosent handle with the => 2)

which i gave in the text i wrote [/B]
[/QUOTE]
Sorry for that!

Have a play with this:

var str='1)dfgsdfgndsfgsdg345234523453245 3245 wdrg wert342 65nsdfgdsfg sdfgewrt rewtert 2)dfg ertwer wenrtwe52345erwtgfsdgq34rt';

alert(str)

str=str.replace(/n/g, ' ').replace('2)','n2)');

alert(str)

Cheers - Pit
Copy linkTweet thisAlerts:
@pelegk1authorMar 06.2005 — seccond i tried to make it something more general in a loop like this :
[code=php]
str=str.replace(/n/g, '<BR>').replace('+"i"+)','n+"i"+)');
[/code]

but it isnt working any idea why?
Copy linkTweet thisAlerts:
@UltimaterMar 06.2005 — Shalom, Mah Shalomcha?
<i>
</i>str=str.replace(/[color=red][/color]n/g, '&lt;BR&gt;').replace(i+")","n"+i+")");
Copy linkTweet thisAlerts:
@pelegk1authorMar 06.2005 — MATAY PAAM HABAA ATA BISRAEL?
Copy linkTweet thisAlerts:
@UltimaterMar 06.2005 — Hayom, Anni Gar BiArtzot Habiret.

HaYiti Lagur BiYisroel lefnay Shuna.

Garti BiYisroel Shanatiyim.

Hayiti Lomad biYeshiva Marbeh Torah baEar Beni Brak.

Affo Atta lomad?
Copy linkTweet thisAlerts:
@pelegk1authorMar 06.2005 — be onivecrytat haifa math+computer science
Copy linkTweet thisAlerts:
@UltimaterMar 06.2005 — [i]Originally posted by pelegk1 [/i]

[B]MATAY PAAM HABAA ATA BISRAEL? [/B][/QUOTE]


Salach le, Anni Tzrech LiSem Lav.

Ali lihachazer liYisroel biod Shanatiyim ,billy nedar.
Copy linkTweet thisAlerts:
@pelegk1authorMar 06.2005 — send me a messag e before
Copy linkTweet thisAlerts:
@pelegk1authorMar 08.2005 — i have for example :

var str='1)dfgsdfgndsfgsdg345234523453245 3245 wdrg wert342 65nsdfgdsfg sdfgewrt rewtert 2)dfg ertwer wenrtwe52345erwtgfsdgq34rt';

str+='n3)dfgsdfgndsfgsdg345234523453245 3245 wdrg wert342 65nsdfgdsfg sdfgewrt rewtert 4)dfg ertwer wenrtwe52345erwtgfsdgq34rt';
[/QUOTE]

and i want it to be :

1)dfgsdfg dsfgsdg345234523453245 3245 wdrg wert342 65 sdfgdsfg dfgewrt rewtert

2)dfg ertwer we rtwe52345erwtgfsdgq34rt

3)dfgsdfg dsfgsdg345234523453245 3245 wdrg wert342 65 sdfgdsfg sdfgewrt rewtert

4)dfg ertwer wenrtwe52345erwtgfsdgq34rt

[/QUOTE]

i dont want inside the section's 1) or 2)... the line will break only automaticlly and it isn't matter if originally there was a n inside that line

thnaks in advane

peleg
Copy linkTweet thisAlerts:
@UltimaterMar 12.2005 — [size=-3]

var str='1)dfgsdfgndsfgsdg345234523453245 3245 wdrg wert342 65nsdfgdsfg sdfgewrt rewtert 2)dfg ertwer wenrtwe52345erwtgfsdgq34rt';

str+='n3)dfgsdfgndsfgsdg345234523453245 3245 wdrg wert342 65nsdfgdsfg sdfgewrt rewtert 4)dfg ertwer wenrtwe52345erwtgfsdgq34rt';

for(i=1;i<10;i++){

str=str.replace(i+")","<br>"+i+")")

}

document.write(str)[/size]
Copy linkTweet thisAlerts:
@pelegk1authorMar 13.2005 — thnaks alot
×

Success!

Help @pelegk1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...