0

I want to make function, that works like Windows' rename function enter image description here.

When you type text and regex is a-zA-Z0-9 then you can type only "alphanumeric" characters. But characters like -, _ or + would be accepted too. Also non-english characters like č š ý ž í á should be accepted too.

4
  • 1
    you can use [^\/:*?"<>|], check this regexr.com > CheatSheet, very useful Commented Oct 11, 2015 at 10:41
  • if I understand right, this regex will take all characters except of these in [...]? Commented Oct 11, 2015 at 10:45
  • except those in [^] Commented Oct 11, 2015 at 10:48
  • Yeas, thanks, XGreen did similar regex in his answer, now its good. Commented Oct 11, 2015 at 10:50

1 Answer 1

2

If you just want to not allow those characters in the bubble then:

function filenameOk(name){
    return !/[\\/:*?<>|]/.test(name);
}

// filenameOk('čšýžíá') --> true
Sign up to request clarification or add additional context in comments.

1 Comment

Actualy, this is regex from comment under my question, so I was right about bubbling them. Thanks, that is usefull, I will also add some my "exceptions" so it will be like I want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.