TaylorBriggs/react-native-typewriter

RegEx in delayMap prop only allows for single character matching

salesp07 opened this issue · 2 comments

In my case, I wanted a longer delay in every end of sentence. So I came up with this RegEx:

const delayMap = [
  // This regular expression matches every last punctuation character. (Using a negative lookahead)
  { at: /[.!?:;](?![.!?:;])/g, delay: 1000 },
];

But with single char RegEx matching (the current implementation), that's impossible.

It's also impossible to insert a delay after matching words, and pretty much every RegEx that's a bit more complex than a single char.

I managed to make a local fix so I'll submit a PR in a bit.

As Taylor mentioned, this package is no longer mantained, so if anyone is interested in these changes, check out my scoped package.