/    Sign up×
Community /Pin to ProfileBookmark

RegEx: Two of (Newline + Whitespace) + alphanumeric. Can’t get it!

I thought one of these would work, but none of them work. Starting with my favorite:

“`
const gRecordDelim = /(n[ t]*){2,}(?=w)/g;
// 2 or more ( newline + 0 or more (spaces or tabs) )
// + any alphanumeric

//const gRecordDelim = /(n[ t]*n)/g;
// const gRecordDelim = /(n[ t]*){2,}(?=[A-Za-z0-9])/g;
// const gRecordDelim = /(n[ t]*){2,}n/g;
// const gRecordDelim = /n{2,}/g;
// const gRecordDelim = /([ t]*n[ t]*){2,}/g;
“`

It’s a split pattern in javascript:

“`
const recs = text.split(gRecordDelim);
recs.forEach((rec) => console.log(“RECORD: ” + rec))
“`

Here’s my data.

“`
const text = `
Orblie Rapitulnik
orbliek.jpg
orbliek.com
There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don’t look even slightly believable.

Qang Le Toenthal
Qang.jpg
Qangle.io
Contrary to popular belief, Lorem Ipsum is not simply random text.`
“`

I’m getting the split at “Qang” as expected, but also splitting at the empty line, which i don’t want.

image![image](https://gcdnb.pbrd.co/images/ju5PQjDeLPLY.png)

also posted to
https://forum.webdeveloper.com/d/402130-regex-two-of-newline-whitespace-alphanumeric-cant-get-it
https://forums.digitalpoint.com/threads/regex-two-of-newline-whitespace-alphanumeric-cant-get-it.2876158/

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 05.2022 — If the intent is to split wherever there is a newline and including any type of following whitespace you could just use something like /ns*/ I would think.
×

Success!

Help @johnywhy 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 4.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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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