- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2022 04:26 PM
Hello.
I'm creating a validator that checks the entered value with a business rule.
Ultimately, I want to allow half-width alphanumeric characters, half-width spaces, and symbols.
Is it possible to create a regular expression that allows all double-byte characters?
Below is the script I am working on.
Only single-byte numbers are allowed.
I want to add a half-width space and a symbol.
Could you tell me how to fix it?
Thanks,
Kentaro.
---
(function executeRule(current, previous /*null when async*/) {
var result = true;
var pattern = new RegExp(/^[a-zA-Z0-9]+$/);
if (!pattern.test(current.u_cpu)) {
gs.addErrorMessage(gs.getMessage("Enter the CPU in single-byte alphanumeric characters."));
current.u_cpu="";
result = false;
}
if(result == false){
current.setAbortAction(true);
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 04:06 PM
I fixed it with the following regular expression. I am checking if it is a 2-byte character.
I am checking if it is a 2-byte character.
[ -~。-゚]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2022 05:34 PM
Hi, there are a number of online regex tools which should help you with your requirement.
regex101: build, test, and debug regex is one example
Based on the details provided I suspect you would need something like
[a-zA-Z0-9]+[ ][-]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 04:06 PM
I fixed it with the following regular expression. I am checking if it is a 2-byte character.
I am checking if it is a 2-byte character.
[ -~。-゚]