In comp.lang.javas cript message <46************ **********@news .free.fr>,
Mon, 24 Sep 2007 10:15:38, Jean-Guy Mouton <us**@example.n etposted:
>I am teaching myself Dom scripting with Javascript. I do not
understand how to get a substring. If I have strings in the form:
"This is string number 1"
How can I put "1" into a variable to use it elsewhere? I thought I
could use the function split and create an array but I have different
string lengths with a variable number of words...
Can you please help me? Thank you.
There are several ways of doing that, depending on how you want to
define the desired extraction.
You might want the 23rd character, or all characters after the 22nd, or
the last character, or the character after the 4th space, or the 5th
"word", or the first set of consecutive octal digits, or the last set of
consecutive decimal digits, etc.
Seek a reference such as <
http://developer.mozilla.org/en/docs/Core_Java
Script_1.5_Refe rence>, and look for appropriate properties of String,
such as charAt, match, substring and substr.
In most cases, at least, one can use a RegExp search; but it may well
not be necessary,
Alternatively, you've used the words Javascript and substring - search
the Web, and you'll soon find references, some being good.
The reference at sussex.ac.uk, though old, is good; and should appear
(unlike most) in your favoured font face and size. I frequently use a
local copy of what it is a copy of.
It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6
news:comp.lang. javascript FAQ <URL:http://www.jibbering.c om/faq/index.html>.
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.