regex

perl6 How to use junction inside regex interpolation?

血红的双手。 提交于 2021-02-08 13:14:41
问题 Sometimes I have a long list and I would like to check whether a string matches anything in the list. I am trying to interpolate a junction inside a regex. They are all errors. say "12345" ~~ m/ <{ (2,3,4).any }> / Cannot resolve caller MAKE_REGEX(Int, Bool, Bool, Int, PseudoStash); none of these signatures match: say "12345" ~~ m/ $( (2,3,4).any ) / This type cannot unbox to a native string: P6opaque, Junction Does this error message mean that junctions cannot be used inside regex

perl6 How to use junction inside regex interpolation?

南笙酒味 提交于 2021-02-08 13:14:28
问题 Sometimes I have a long list and I would like to check whether a string matches anything in the list. I am trying to interpolate a junction inside a regex. They are all errors. say "12345" ~~ m/ <{ (2,3,4).any }> / Cannot resolve caller MAKE_REGEX(Int, Bool, Bool, Int, PseudoStash); none of these signatures match: say "12345" ~~ m/ $( (2,3,4).any ) / This type cannot unbox to a native string: P6opaque, Junction Does this error message mean that junctions cannot be used inside regex

perl6 How to use junction inside regex interpolation?

拟墨画扇 提交于 2021-02-08 13:14:17
问题 Sometimes I have a long list and I would like to check whether a string matches anything in the list. I am trying to interpolate a junction inside a regex. They are all errors. say "12345" ~~ m/ <{ (2,3,4).any }> / Cannot resolve caller MAKE_REGEX(Int, Bool, Bool, Int, PseudoStash); none of these signatures match: say "12345" ~~ m/ $( (2,3,4).any ) / This type cannot unbox to a native string: P6opaque, Junction Does this error message mean that junctions cannot be used inside regex

PostgreSQL UPDATE substring replacement

99封情书 提交于 2021-02-08 12:21:20
问题 I have a few rows in a test database where there are dollar signs prefixed to the value. I want to UPDATE the values in the name row of the test1 table however when I threw the following query together it emptied the six rows of data in the name column... UPDATE test1 SET name=overlay('$' placing '' from 1 for 1); So "$user" became "" when I intended for that column/row value to become "user". How do I combine UPDATE and a substr replacement without deleting any of the other data? If there

PostgreSQL UPDATE substring replacement

China☆狼群 提交于 2021-02-08 12:21:17
问题 I have a few rows in a test database where there are dollar signs prefixed to the value. I want to UPDATE the values in the name row of the test1 table however when I threw the following query together it emptied the six rows of data in the name column... UPDATE test1 SET name=overlay('$' placing '' from 1 for 1); So "$user" became "" when I intended for that column/row value to become "user". How do I combine UPDATE and a substr replacement without deleting any of the other data? If there

Index Bounds on Mongo Regex Search

陌路散爱 提交于 2021-02-08 12:20:25
问题 I'm using MongoDB, and I have a collection of documents with the following structure: { fName:"Foo", lName:"Barius", email:"fbarius@example.com", search:"foo barius" } I am building a function that will perform a regular expression search on the search field. To optimize performance, I have indexed this collection on the search field. However, things are still a bit slow. So I ran an explain() on a sample query: db.Collection.find({search:/bar/}).explain(); Looking under the winning plan, I

regex that checks if the string starts with two upper-case followed by numbers

孤街浪徒 提交于 2021-02-08 12:16:38
问题 Hi Guys I need a regex that checks if the string starts with two upper-case followed by numbers : Example: DE123456789 Thanx a lot of. 回答1: Literally: ^[A-Z]{2}\d+ ^ - start of the string [A-Z] - an upper case letter {2} - two of those \d - a digit + - one or more of those 来源: https://stackoverflow.com/questions/32038690/regex-that-checks-if-the-string-starts-with-two-upper-case-followed-by-numbers

How to split String without regex [duplicate]

耗尽温柔 提交于 2021-02-08 12:16:34
问题 This question already has answers here : String.split() *not* on regular expression? (8 answers) Closed 5 days ago . In my Java application I need to find indices and split strings using the same "target" for both occasions. The target is simply a dot. Finding indices (by indexOf and lastIndexOf) does not use regex, so String target = "."; String someString = "123.456"; int index = someString.indexOf(target); // index == 3 gives me the index I need. However, I also want to use this "target"

Perl comprehensive phone number regex [duplicate]

牧云@^-^@ 提交于 2021-02-08 12:12:43
问题 This question already has answers here : How to validate phone numbers using regex (42 answers) Closed 2 years ago . I have a file that contains phone numbers of the following formats: (xxx) xxx.xxxx (xxx).xxx.xxxx (xxx) xxx-xxxx (xxx)-xxx-xxxx xxx.xxx.xxxx xxx-xxx-xxxx xxx xxx-xxxx xxx xxx.xxxx I must parse the file for phone numbers of those and ONLY those formats, and output them to a separate file. I'm using perl, and so far I have what I think is a valid regex for two of these numbers my

Python - find a substring between two strings based on the last occurence of the later string

£可爱£侵袭症+ 提交于 2021-02-08 12:12:07
问题 I am trying to find a substring which is between to strings. The first string is <br> and the last string is <br><br> . The first string I look for is repetitive, while the later string can serve as an anchor. Here is an example: <div class="linkTabBl" style="float:left;padding-top:6px;width:240px"> Anglo American plc <br> 20 Carlton House Terrace <br> SW1Y 5AN London <br> United Kingdom <br><br> Phone : +44 (0)20 7968 8888 <br> Fax : +44 (0)20 7968 8500 <br> Internet : <a class="pageprofil