/    Sign up×
Community /Pin to ProfileBookmark

regular expression Question

Here is what I’m trying to do:
-asigne to an Array the value of each of the following lignes:

«
Chauffe-piscine
Foyer fournaise ( Max. 50 000 BTU / h )
Foyer-climatisant
Climatiseur-central
Surchauffeur eau chaude sanitaire (accessoires en option)
Chauffe résidentiel 1° génération ( Max. 60 000 BTU / h )

Chauffe-eau ( Max. 60 000 BTU / h )

Chauffe locatif 1° génération ( Max. 390 000 BTU / h )
Multi-locatif 2° génération ( Max. 390 000 BTU / h )
Chauffe-eau 3° génération ( Max. 390 000 BTU / h )
»

Note the amount of lignes and lenght are not known in advance. All I know is they all start with a capital ([A-Z]) and they all end with a carriage return (r).

What I would love to is say:
from [A-Z] (included) to r (excluded) asigne to Array and keep on going to the end of input.

Here is some of what I tryed:

string.match(/[A-Z]S+s(?!r)/g);
the probleme here is I need to repeat the sequence «S+s(?!r)» an unknown amount of times…

this does not seem to work either:
«/[A-Z](S+s(?!r))+/g»

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@CharlesOct 26.2003 — [font=monospace]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="Content-Script-Type" content="text/javascript">

<title>Example</title>

<script type="text/javascript">

<!--

onload = function () {a = document.getElementById('data').value.split(/n/); for (line in a) {alert (a[line])}}

// -->

</script>

<textarea id="data">Chauffe-piscine

Foyer fournaise ( Max. 50 000 BTU / h )

Foyer-climatisant

Climatiseur-central

Surchauffeur eau chaude sanitaire (accessoires en option)

Chauffe résidentiel 1° génération ( Max. 60 000 BTU / h )

Chauffe-eau ( Max. 60 000 BTU / h )

Chauffe locatif 1° génération ( Max. 390 000 BTU / h )

Multi-locatif 2° génération ( Max. 390 000 BTU / h )

Chauffe-eau 3° génération ( Max. 390 000 BTU / h )</textarea>[/font]
Copy linkTweet thisAlerts:
@Ice3TauthorOct 26.2003 — ... the word Jedi comes to mind.

Thank you Yoda... Euh, I mean Charles.
Copy linkTweet thisAlerts:
@Ice3TauthorOct 26.2003 — Hi, I just noticed that the values of the a Array

« a = document.getElementById('data').value.split(/n/); »

have a nasty space " " at the end of them. I would like to modify the code so that this does not happen,

thank you again,
Copy linkTweet thisAlerts:
@CharlesOct 26.2003 — [font=monospace]onload = function () {a = document.getElementById('data').value.split(/s*n/); alert (a)}[/font]
Copy linkTweet thisAlerts:
@Ice3TauthorOct 26.2003 — Many thanks,
×

Success!

Help @Ice3T 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...