posix-ere

POSIX character equivalents in Java regular expressions

て烟熏妆下的殇ゞ 提交于 2019-12-05 10:40:30
I would like to use a regular expression like this in Java : [[=a=][=e=][=i=]] . But Java doesn't support the POSIX classes [=a=], [=e=] etc . How can I do this? More precisely, is there a way to not use US-ASCII? Java does support posix character classes . The syntax is just different, for instance: \p{Lower} \p{Upper} \p{ASCII} \p{Alpha} \p{Digit} \p{Alnum} \p{Punct} \p{Graph} \p{Print} \p{Blank} \p{Cntrl} \p{XDigit} \p{Space} Quoting from http://download.oracle.com/javase/1.6.0/docs/api/java/util/regex/Pattern.html POSIX character classes (US-ASCII only) \p{Lower} A lower-case alphabetic

PCRE to POSIX assistance

牧云@^-^@ 提交于 2019-12-02 05:06:17
问题 I need to extract the profile for these syslog entries. May 11 09:35:59 server-0548 ea_appserver: env=ACPT profile=product_api java[31185]: 2017-05-11 09:35:59,210 server-0548 org.hibernate.internal.SessionFactoryImpl ServerService Thread Pool -- 51 HHH000008: JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession() The following regex works for PCRE but I can't seem to convert it over to POSIX. (?m)profile=(\S+) I've tried [^=]*

PCRE to POSIX assistance

只愿长相守 提交于 2019-12-02 01:54:10
I need to extract the profile for these syslog entries. May 11 09:35:59 server-0548 ea_appserver: env=ACPT profile=product_api java[31185]: 2017-05-11 09:35:59,210 server-0548 org.hibernate.internal.SessionFactoryImpl ServerService Thread Pool -- 51 HHH000008: JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession() The following regex works for PCRE but I can't seem to convert it over to POSIX. (?m)profile=(\S+) I've tried [^=]*$ and .*profile=(.*) but can't get either to stop at just product_api POSIX ERE does not support inline

Match digits in [g]awk

我与影子孤独终老i 提交于 2019-12-02 01:39:00
I'm stumped! Trying to write an awk regex to match a string against 11 digits. I've tried: if (var ~ /^[0-9]{11}$/ ) if (var ~ /^([0-9]){11}$/ ) if (var ~ /^([0-9]{11})$/ ) if (var ~ /^[0-9]{11}/ ) # altho I really do need to check the whole str if (var ~ /[0-9]{11}/ ) If I use this.... if (var ~ /^[0-9]+/ ) Then I get a match - but I need to check for exactly 11 digits. You described your problem, but didn't tell us your awk version. It is an important information. but this may work for your case: if (var ~ /^[0-9]+$/ && length(var)==11) If we know the version, there could be simpler solution

ereg_replace for PHP 5.3 +?

…衆ロ難τιáo~ 提交于 2019-12-01 12:47:16
I've seen a solution for not having to rework usage of the ereg function for PHP 5.3: Good alternative to eregi() in PHP It uses if(!function_exists.... Is there a function that can be used in this way for ereg_replace ? ereg_replace("<!--.*-->","",$str); ereg_replace("[^a-z,A-Z]", "", $str); Use the PCRE function preg_replace instead: preg_replace("/<!--.*-->/", "", $str); preg_replace("/[^a-z,A-Z]/", "", $str); POSIX ERE is (nearly) a complete subset of PCRE. So you can use (nearly) any POSIX ERE regular expression with a PREG implementation. See the Regular Expression Flavor Comparison for

What is the difference between split() and explode()?

不问归期 提交于 2019-11-30 04:19:40
The PHP manual for split() says This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged...Use explode() instead. But I can't find a difference between split() and explode() . join() hasn't been deprecated, so what gives? It's been deprecated because explode() is substantially faster because it doesn't split based on a regular expression, so the string doesn't have to be analyzed by the regex parser preg_split() is faster and uses PCRE regular expressions for regex splits join() and implode() are aliases of each other and therefore don't have any

Why is `ereg` deprecated in PHP?

余生颓废 提交于 2019-11-29 11:32:46
Why is ereg deprecated in PHP? I had a lot of functions which used this, now they always give warning. What is the alternative of this too? http://pl.php.net/manual/en/function.ereg.php Note: As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED notice. See the list of differences for help on converting to PCRE. abelito Ereg is deprecated because it was replaced by the the PCRE extension. The reason(s) it was replaced and deprecated is answered in the below link, but to save you some time here is the copy and pasted

ereg_replace to preg_replace?

风流意气都作罢 提交于 2019-11-29 03:57:49
How can I convert ereg_replace(".*\.(.*)$","\\1",$imgfile); to preg_replace... ? ? I'm having trouble with it? preg_replace("/.*\.(.*)$/", "\\1", "foo.jpg") I don't know why PHP requires the / delimiters. The only reason Perl, JS, etc. have them is that they allow regex literals, which PHP doesn't. Sumoanand You should know 4 main things to port ereg patterns to preg: Add delimiters (/): 'pattern' => '/pattern/' Escape delimiter if it is a part of the pattern: 'patt/ern' => '/patt\/ern/' Achieve it programmatically in following way: $ereg_pattern = '<div>.+</div>'; $preg_pattern = '/'

PHP ereg vs. preg

99封情书 提交于 2019-11-29 02:49:21
I have noticed in the PHP regex library there is a choice between ereg and preg. What is the difference? Is one faster than the other and if so, why isn't the slower one deprecated? Are there any situations where it is better to use one over the other? Visiting php.net/ereg displays the following: Warning This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged. Down the page just a bit further and we read this: Note: preg_match(), which uses a Perl-compatible regular expression syntax, is often a faster alternative to ereg().

How to replace ereg?

我的未来我决定 提交于 2019-11-28 12:08:46
I'm getting the following message for some php I have to use but did not write: Deprecated: Function ereg() is deprecated in /opt/lampp/htdocs/webEchange/SiteWeb_V5/inc/html2fpdf.php on line 466 This is line 466: if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3)) I tried simply replacing with preg_match, but it couldn't recognize the = modifier in the regular expression.. I'm not too good with regular expression yet and solving this requires that I learn the regexp ereg needs AND the regexp preg_match needs (which, if I am not mistaken, is different)... Could you guys help me out with this one