'REGEX : accept only alphanumeric characters and spaces except the spaces at the begining or ending of expression
I need to implement regular expression that accept only alphanumeric characters and spaces except the spaces at the begining or ending of expression.
' aaaa978aa' ===> fail
'aaaaaa ' ===> fail
'aaaaaaaaAAAa' ===> match
'aaaaaaa aaa' ===> match
'68776 67576' ===> match
'aAAAa756Gaaa' ===> match
Solution 1:[1]
Try this:
^\w+(?:[ \t]+)?\w+$
^ : Asserts position at start of a line
\w+ : Matches any word character (equivalent to [a-zA-Z0-9_]), between one and unlimited times.
(?:[ \t]+)? : Non capturing group, matches the spaces and tab, ? ensures to match the previous token between 0 and 1 time.
$: Asserts position at end of a line
Solution 2:[2]
As mentioned by Oleg Flores answer for correct header, and the notice in his comment, that we should use the buffer from the object, that in the case of not saving any file by Multer, values of the insert query should be
[ q.body.filerefid, q.file.buffer]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | ALMEK |
