Issues with strings and regular expressions in ruby

Source: Internet
Author: User

The ruby regular expression is a Regexp class object.

Main metacharacters

Sn

Meaning

Example

Xiaoming

^

Header

/^ ABC/

ABC begin

$

End of line

/ABC $/

ABC too many rows

.

Any limit 1 Text

/A. B/

A between B between 1 Text

[...]

[] Inner limit 1 Text

/[A-Za-Z]/

English

[^...]

[] The inner vertex contains the inner vertex 1 text.

/[^ 0-9]/

Not a number

*

0 or more

/.*/

A worker starts worker

+

1 or more

/A +/

1 or more times

?

0-back rollback-1-back

/AA? /

A few minutes without AA

A | B

A worker B

/^ (ABC) | (ABC) $/

ABC too many ABC too rows

(...)

Zookeeper regionalization

/(ABC) +/

When ABC returns a response, more than one response is returned.

\ W

English digit comment _

/^ \ W + $/

English digit comment _ blank Comment comment row

\ W

Outside of the English digit limit _

/Hello, \ Wworld/

Hello, there is a world outside the English number comment _
1 Text

\ S

Blank text

/Hello, \ sworld/

Hello, please world blank text

\ S

Other than blank text

/Hello \ sworld/

Hello, there is no space for reading 1 Text

\ D

Number

/A \ D/

A branch number 1 Text

\ D

Not a number

/A \ D/

A: 1 text not included in the number

The result is as follows:
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.