unjs / magic-regexp

A compiled-away, type-safe, readable RegExp alternative

Home Page:https://regexp.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

differentiate lowercase letter, uppercase letter, or combine them

hi-reeve opened this issue Β· comments

πŸ†’ Your use case

right now the function letter is include all the uppercase and lowercase letter, my use case is i only need the lowercase letter, and uppercase letter is prohibited.

πŸ” Alternatives you've considered

No response

ℹ️ Additional info

No response

Maybe we can add letter.lowercase and letter.uppercase
Thanks for suggestion! πŸ‘

Hey πŸ‘‹,

I'm interested in working on this!
I'm not too sure how to approach the API design, however.

@didavid61202, are you suggesting that letter becomes:

const letter: Input<"[a-zA-Z]", never, []> & {
    lowercase: Input<"[a-z]", never, []>,
    uppercase: Input<"[A-Z]", never, []>,
}

?

Otherwise, we could expand the API to include standalone lowercase and uppercase Inputs...

 export const whitespace = createInput('\\s')
 export const letter = createInput('[a-zA-Z]')
+export const lowercase = createInput('[a-z]')
+export const uppercase = createInput('[A-Z]')
 export const tab = createInput('\\t')

I'd like to get it done as part of the Hacktoberfest event, so... as soon as we've settled on an API, I'm raring to get started!

Yes, I think that the first option was what @didavid61202 was suggesting, and makes sense.

Also very happy to include other constructed inputs alongside letter/tab, but lower/upper-case makes sense to access within dot notation.