Home>

I want to set a regular expression under the following conditions.

conditions
Any character will match as long as it is 2 or more characters.
However, spaces are not counted as one character. (Not including full-width and half-width)

Example
[A] [a] [1] → Because it is a single character, it does not match
[A] [a] [1] → Even if it is half-width or full-width, it does not match because spaces are not counted as characters.
[Ai] [Ai] [Ai] → Matches because there are two or more characters

Current status
/.+\S/


If i write, [A] will also match.
I don't want to count whitespace as a single character if there is a whitespace before the character. What should I do?
Thanks for your professor.

  • Answer # 1

    I think it is better to "count the number of characters after removing whitespace" without using regular expressions.
    Since the purpose is expressed straight, it is easy to understand even afterwards.

    If it is a regular expression, double-byte spaces are also included\ sIf the language is judged to be\ S \ s * \ SIs it?
    Not so with Ruby (double-byte spaces are\ sDoes not match), so it also matches double-byte spaces[: space:]Using,
    [^ [: space:]] [[: space:]] * [^ [: space:]]Or([^ [: space:]] [[: space:]] *) {2,}
    Is not it. It's hard to understand at first glance. ([: space:]Is\ sSince it is an extension of, including line breaks etc.)
    Or this is not good because it is invisible,
    [^] [] * [^]And([^] [] *) {2,}
    Do you write half-width and full-width spaces?