Re: javascript help (UNCLASSIFIED)

From: Bartikowski, Waldemar <bartikowskiw_at_nyob>
Date: Thu, 18 Jan 2018 16:56:11 +0000
To: CODE4LIB_at_LISTS.CLIR.ORG
Hi Kelly,


use Regular Expressions <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp>. This should be the easiest way to go:


---


var matching = "matching string 12345";
var not_matching = "not matching string 12a42";

// This checks if the last five characters are digits
var regex = /\d{5}$/;

alert( regex.test( matching ) );
alert( regex.test( not_matching ) );

---

Waldemar Bartikowski


________________________________
From: Code for Libraries <CODE4LIB_at_LISTS.CLIR.ORG> on behalf of Zhu, Kaile NAF USARMY IMCOM HQ (US) <kaile.zhu.naf_at_MAIL.MIL>
Sent: Thursday, January 18, 2018 10:47
To: CODE4LIB_at_LISTS.CLIR.ORG
Subject: [CODE4LIB] javascript help (UNCLASSIFIED)

CLASSIFICATION: UNCLASSIFIED

Anybody can help me with such JavaScript code that can chop the ending portion of the string - last 5 characters - verifying if it is all numbers (zip code)?

Thanks.

Kelly Zhu

CLASSIFICATION: UNCLASSIFIED
Received on Thu Jan 18 2018 - 11:56:21 EST