Inputmask icon indicating copy to clipboard operation
Inputmask copied to clipboard

Request: Casing for Regex-Patterns

Open monomorph opened this issue 8 years ago • 7 comments

I'm using the inputmak-plugin intensively with Regex patterns. Here's a request for the casing options:

  • In addition to the existing options "upper", "lower", "title" it would be nice to have "regex" by means that this option would ensure casing at every position.
  • Example pattern: [A-Z][a-z]-[A-Z][a-z]
  • This would allow inputs like "Ab-De" or "Az-Za", ...
  • Code:
$(inputElementId).inputmask({
            regex: "[A-Z][a-z]-[A-Z][a-z]",
            casing: null, //here I'd like to use "regex"
        });
  • This would allow to get the casing automatically done, "upper" at positions 1 and 4, "lower" at positions 2 and 5.

Too weird?

monomorph avatar Aug 08 '18 12:08 monomorph

@monomorph ,

You can pass a callback to the casing option see docs.

casing: function(elem, test, pos, validPositions) { return yourmanipulated charvalue }

RobinHerbots avatar Aug 09 '18 08:08 RobinHerbots

@RobinHerbots: Ah, looks great! I'll check this out...

monomorph avatar Aug 09 '18 09:08 monomorph

@RobinHerbots: Works like a charm! Had to update my inputmask.bundle. I tested with 4.0.1-beta.25. Which is the latest stable version supporting the casing: function{} option?

monomorph avatar Aug 09 '18 11:08 monomorph

@RobinHerbots: I switched to 4.0.0 for more tests. Can it be that RegEx number ranges are not supported anymore? Sth. like "[0-9]" within a RegEx pattern is not evaluated anymore?

I was on 3.3.6-10, where it was working.

monomorph avatar Aug 09 '18 12:08 monomorph

@monomorph ,

Can you provide an example of the regex.

RobinHerbots avatar Aug 09 '18 12:08 RobinHerbots

Ooops, false alarm. I was on Caps Lock... Pardon me!

I'll do some more testing and let you know...

monomorph avatar Aug 09 '18 12:08 monomorph

@monomorph ,

Can this be closed?

RobinHerbots avatar Oct 16 '18 16:10 RobinHerbots