Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 days ago.
Improve this question
Both seem to work, but which should I use?
In Chinese character encoding, Unicode is a standard character set that contains characters from various languages. In Unicode, the encoding range of Chinese characters is \u4e00-\u9fa5.
In some cases, however, you may see the Kanji character set in the encoding range \u4e00-\u9eff being used. This is because in the early Unicode standard, the encoding range of the Chinese character set was \u4e00-\u9fff, which contained some non-Chinese characters, so it was later revised to \u4e00-\u9fa5, which only contained Chinese characters.
Therefore, \u4e00-\u9fa5 is the standard encoding range of Chinese characters, while \u4e00-\u9eff includes some non-Chinese characters. When recognizing Chinese, the range \u4e00-\u9fa5 should be used to ensure that only Chinese characters are matched.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I need to validate the filenames before a upload. I thought regex would be the perfect solution for that, but I don't have a clue of regex.
The filenames have all a specific structure.
What I tried myself is: /([-\d]{2,})_([a-zA-Z\d]+)/, but this will only match the first numbers and the first tag in the filename.
Example: 100_test-tag1-tag2.gif or 100_test_tag1-tag2.gif
The files have to start with a number and after the number should be a underscore. After that it should at least have one part with a tag. The tags can be separated by a underscore or a hyphen. The tags can occur an infinite number of times. The file ending should be .gif.
Your attempt is almost complete:
Try this:
/([-\d]{2,})_([a-zA-Z\d]+)([_-][a-zA-Z\d]+)*\.gif/
I added this:
([_-][a-zA-Z\d]+)*
which matches an _ or - followed by a tag zero ore more times.
And
\.gif
which matches the trailing .gif.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Say I have a regex pattern like this:
/^\*HELLO\*/
Just looking for the string "*HELLO*". But then I completely want to change it up so I do this:
/^\*&$&^*2#H\*/
Now I'm looking for the string "*&$&^*2#H*".
How should I change my regex pattern to check for such a complex string with all those different characters?
You should escape the special characters in your pattern, wich are used as tokens by Regex, such as *,^ and $. Or you will end up with an error claiming about a wrong pattern in your regex.
This is how should be your regex: /\*&\$&\^\*2#H\*/.
Furthermore if you are searching for the string with .indexOf() or .includes() methods, you can just pass the string as it is.
str.indexOf("^\*&$&^*2#H\*");
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Which is the common best practice for where to place parenthesis after a function? I see at times function () and I see function(). With parameters I see function (param) and then I see function(param. Is this just a matter of preference or is there a reason as to why there would be whitespace after the function or there would not be whitespace?
JavaScript is not white space sensitive.you define your coding style.
Though having white space between the function and parenthesis is no sin. If you follow crockford's javascript standards. He advises not to have space in between.
http://javascript.crockford.com/code.html#function
The size of the indent is usually independent of the style. Many early
programs used tab characters for indentation, for simplicity and to
save on source file size. Unix editors generally view tabs as
equivalent to eight characters, while Macintosh and Microsoft Windows
environments would set them to four, creating confusion when code was
transferred back and forth. Modern programming editors are now often
able to set arbitrary indentation sizes, and will insert the
appropriate combination of tabs and spaces. For Ruby, many shell
programming languages, and some forms of HTML formatting, two spaces
per indent level is generally used.
Read full on Code Indent Style in Programming
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want a regular expression that checks if a string contains only the allowed characters. The allowed characters are alphanumeric and the special characters (),#\/\-. I used this expression, and it is working fine.
/^([A-Za-z0-9 .(),#\/\-]*)+$/
Now I don't want the string to start with space or any disallowed characters, but it can have space in the middle. Also, the string may not consist of only special characters; it should have at least one alphanumeric character.
Can someone help me understand how to adapt the regex I am using to check these additional constraints?
^(?=[a-zA-Z0-9])([A-Za-z0-9 .(),#\/-]*)+$
This should do it.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a collection of all uppercase address names and numbers and I want to extract just the first encountered address number for each address. The following examples show what I would like to extract from each:
80 ROSE COTTAGE -> 80
80A ROSE COTTAGE -> 80A
80 A ROSE COTTAGE -> 80 A
80ROSE COTTAGE -> 80 (accidental no-space)
[ANY OTHER TEXT] 80 ROSE COTTAGE -> 80
I have found some similar questions answered here and elsewhere on the internet, but they always deal with an address as a whole as opposed to specifically just address name and number:
Match each address from the address number to the 'street type'
regex street address match
Regular Expression: Any character that is NOT a letter or number
javascript regular expressions address number
JavaScript regex to validate an address
The last one makes reference to a lookahead, which lead me to construct a negative look ahead for any alphanumeric characters following a potential single text character(eg. 80 A) in my JavaScript regex. However without adding the alternative "digits only found" group (\d+) my fourth example above does not return just the number.
(?:\d+\s*[A-Z]?(?![A-Z0-9]))|(?:\d+))
Is there a way to combine these two groups into a single regex expression? Or is this not possible in JavaScript's regex implementation?
Any help with this would be greatly appreciared.
(\d+\s*(?:[A-Z](?![A-Z]))?)
You can try this.
See demo.
http://regex101.com/r/kM7rT8/13