Skip to content
Advertisement

Need regex for project name with the following conditions

Need regex for the “Project name” with following condition. Expected Result: Take alphabetical, alpha numeric, alpha numeric symbolic Actual Result:

JavaScript

that is, Everything is allowed but if it is just special characters and no text than it’s a problem. **Example:

  • zjna5726$7&^#bsg //allowed
  • %&*% // just special characters not allowed
  • I tried /^[ A-Za-z0-9_@./#&+-]*$/ but did not help
  • ^([w+d+]+)((-)([w+d+]+))* //did not help it is only excepting one character in between only.

Advertisement

Answer

^(?=[W_]+[a-zA-Z0-9]|[a-zA-Z0-9]+[W_]|[a-zA-Z0-9]+).+$ – This regex should fulfil your requirement.

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement