/    Sign up×
Community /Pin to ProfileBookmark

regular expression query

Hi all,

I’m trying to formulate a regular expression which can ask

[code=html]
if (the 30th character in the string is ‘.’) {
do xyz}
[/code]

It’s for a programme in which the user will send one of several of replies, only one of which I want to make the programme “do xyz”.

Many thanks,

futureboy

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@FangJan 16.2009 — if(str.charAt(29)=='.') {
do xyz
}
Copy linkTweet thisAlerts:
@futureboyauthorJan 16.2009 — Hi all,

I'm trying to build a simple line of coding which says "when the 30th character is '.' add one to the score." I'm having trouble getting the score to return in an alert, perhaps becaues there is no "else" clause following the "if."

So far I've got this,

[code=html]function yourscore() {
var score = 0

if(document.survey.one.value[i].charAt(29)=='.') {
score++}

alert(score)
}
[/code]


Any ideas?
Copy linkTweet thisAlerts:
@FangJan 16.2009 — This looks wrong:document.survey.one.value[i]What is it?
×

Success!

Help @futureboy 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,
)...