Search Results

Search found 6394 results on 256 pages for 'regular expressions'.

Page 12/256 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Combine regular expressions for splitting camelCase string into words

    - by stou
    I managed to implement a function that converts camel case to words, by using the solution suggested by @ridgerunner in this question: Split camelCase word into words with php preg_match (Regular Expression) However, I want to also handle embedded abreviations like this: 'hasABREVIATIONEmbedded' translates to 'Has ABREVIATION Embedded' I came up with this solution: <?php function camelCaseToWords($camelCaseStr) { // Convert: "TestASAPTestMore" to "TestASAP TestMore" $abreviationsPattern = '/' . // Match position between UPPERCASE "words" '(?<=[A-Z])' . // Position is after group of uppercase, '(?=[A-Z][a-z])' . // and before group of lowercase letters, except the last upper case letter in the group. '/x'; $arr = preg_split($abreviationsPattern, $camelCaseStr); $str = implode(' ', $arr); // Convert "TestASAP TestMore" to "Test ASAP Test More" $camelCasePattern = '/' . // Match position between camelCase "words". '(?<=[a-z])' . // Position is after a lowercase, '(?=[A-Z])' . // and before an uppercase letter. '/x'; $arr = preg_split($camelCasePattern, $str); $str = implode(' ', $arr); $str = ucfirst(trim($str)); return $str; } $inputs = array( 'oneTwoThreeFour', 'StartsWithCap', 'hasConsecutiveCAPS', 'ALLCAPS', 'ALL_CAPS_AND_UNDERSCORES', 'hasABREVIATIONEmbedded', ); echo "INPUT"; foreach($inputs as $val) { echo "'" . $val . "' translates to '" . camelCaseToWords($val). "'\n"; } The output is: INPUT'oneTwoThreeFour' translates to 'One Two Three Four' 'StartsWithCap' translates to 'Starts With Cap' 'hasConsecutiveCAPS' translates to 'Has Consecutive CAPS' 'ALLCAPS' translates to 'ALLCAPS' 'ALL_CAPS_AND_UNDERSCORES' translates to 'ALL_CAPS_AND_UNDERSCORES' 'hasABREVIATIONEmbedded' translates to 'Has ABREVIATION Embedded' It works as intended. My question is: Can I combine the 2 regular expressions $abreviationsPattern and camelCasePattern so i can avoid running the preg_split() function twice?

    Read the article

  • Why does this regular expression fail?

    - by Stephen
    I have a password validation script in PHP that checks a few different regular expressions, and throws a unique error message depending on which one fails. Here is an array of the regular expressions and the error messages that are thrown if the match fails: array( 'rule1' => array( '/^.*[\d].*$/i', 'Password must contain at least one number.' ), 'rule2' => array( '/^.*[a-z].*$/i', 'Password must contain at least one lowercase letter' ), 'rule3' => array( '/^.*[A-Z].*$/i', 'Password must contain at least one uppercase letter' ), 'rule4' => array( '/^.*[~!@#$%^&*()_+=].*$/i', 'Password must contain at least one special character [~!@#$%^&*()_+=]' ) ); For some reason, no matter what I pass through the validation, the "Special Characters" rule fails. I'm guessing it's a problem with the expression. If there's a better (or correct) way to write these expressions, I'm all ears!

    Read the article

  • Hyper-V cluster VS regular cluster

    - by Sasha
    We need to choice between Hyper-V and regular cluster technologies. What is the advantage and disadvantage of these approaches? Update: We have to physical servers and want to build reliably solution using cluster approach. We need to clustering our application and DB (MS SQL). We know that we can use: Regular Windows Cluster Service. Application and DB will be migrating from one node to other. Hyper-V Failover Cluster. Virtual machine will be migrating from one node to other. Combined variant. DB mirroring for MS SQL and Hyper-V for our application. We need to make a choice between this approach. So we need to know advantage and disadvantage of these approaches?

    Read the article

  • oddities in interference of linux extened ACLs and 'regular' permissions

    - by abbot
    I've got some legacy code which checks that some file is read-only and readable only by it's owner, i.e. permissions set to 0400. I also need to give read-only access to this file to some other user on the system. I'm trying to set extended ACLs, but this changes 'regular' permission bits in a strange way also: $ ls -l hostkey.pem -r-------- 1 root root 0 Jun 7 23:34 hostkey.pem $ setfacl -m user:apache:r hostkey.pem $ getfacl hostkey.pem # file: hostkey.pem # owner: root # group: root user::r-- user:apache:r-- group::--- mask::r-- other::--- $ ls -l hostkey.pem -r--r-----+ 1 root root 0 Jun 7 23:34 hostkey.pem And after this the legacy code starts complaining that the file is group-readable (while it is actually not!) Is it possible to set the extended ACLs in such a way that some other user will also have read-only access, while the file will appear to have only 0400 'regular' permissions?

    Read the article

  • /dev/null file became regular file

    - by user197719
    In our production server suddenly /dev/null became a regular file and due to this sshd service got stopped and not able to login the server. And also we tried to the below steps to configure back to character device file, rm -rf /dev/null mknod /dev/null c 1 3 As soon as we run the rm command /dev/null is being re-created as a regular file before mknod can run. We can't figure out how this happening and which component is creating this file. So until we solve this issue we are unable to create /dev/null as character device file.

    Read the article

  • Regular expressions and the question mark

    - by James P.
    I'm having trouble finding a regular expression that matches the following String. Korben;http://feeds.feedburner.com/KorbensBlog-UpgradeYourMind?format=xml;1 One problem is escaping the question mark. Java's pattern matcher doesn't seem to accept \? as a valid escape sequence but it also fails to work with the tester at myregexp.com. Here's what I have so far: ([a-zA-Z0-9])+;http://([a-zA-Z0-9./-]+);[0-9]+ Any suggestions?

    Read the article

  • Is there a compelling reason to use quantifiers in Perl regular expressions instead of just repeatin

    - by Morinar
    I was performing a code review for a colleague and he had a regular expression that looked like this: if ($value =~ /^\d\d\d\d$/) { #do stuff } I told him he should change it to: if ($value =~ /^\d{4}$/) { #do stuff } To which he replied that he preferred the first for readability (I find the second more readable, but that's a religious debate I'll save for another day). My question: is there an actual benefit to one over the other?

    Read the article

  • Regular expressions and matching question marks in URLs

    - by James P.
    I'm having trouble finding a regular expression that matches the following String. Korben;http://feeds.feedburner.com/KorbensBlog-UpgradeYourMind?format=xml;1 One problem is escaping the question mark. Java's pattern matcher doesn't seem to accept \? as a valid escape sequence but it also fails to work with the tester at myregexp.com. Here's what I have so far: ([a-zA-Z0-9])+;http://([a-zA-Z0-9./-]+);[0-9]+ Any suggestions?

    Read the article

  • Good starting point to learn regular expressions.

    - by Jeremy Rudd
    I'm good at learning new languages and platforms, though whenever I try to learn Reg Ex I cannot make sense of it. I once even used the Regular Expression Designer to try and put some together. What's a good starting point to understanding what looks like the only rocket-science programming language in the world? Links to articles, books or anything else that could help me get my grounding would be appreciated.

    Read the article

  • Finding C#-style unescaped strings using regular expressions

    - by possan
    I'm trying to write a regular expression that finds C#-style unescaped strings, such as string x = @"hello world"; The problem I'm having is how to write a rule that handles double quotes within the string correctly, like in this example string x = @"before quote ""junk"" after quote"; This should be an easy one, right?

    Read the article

  • inotifywait usage and exclude

    - by user58542
    I want to monitor special path to any event of create or modified files recursively in it via inotifywait but i cant know what's problem. i have some folder that i want to exclude thame. watchpath -> folder1 -> file1 -> ingnorefile1 [IG] -> ignorefolder1 [IG] i have problem to exclude them. inotifywait -mr --exclude '(ignorefolder1|folder1\/ingnorefile1)' -e modify -e create -e delete . | while read date time dir file; do what is correct regular expression ?

    Read the article

  • Python regular expressions matching variables to end of line

    - by None
    When you use variables (is that the correct word?) in python regular expressions like this: "blah (?P\w+)" ("value" would be the variable), how could you make the variable's value be the text after "blah " to the end of the line or to a certain character not paying any attention to the actual content of the variable. For example, this is pseudo-code for what I want: >>> import re >>> p = re.compile("say (?P<value>continue_until_text_after_assignment_is_recognized) endsay") >>> m = p.match("say Hello hi yo endsay") >>> m.group('value') 'Hello hi yo' Note: The title is probably not understandable. That is because I didn't know how to say it. Sorry if I caused any confusion.

    Read the article

  • Fuzzy Regular Expressions

    - by Thomas Ahle
    In my work I have with great results used approximate string matching algorithms such as Damerau–Levenshtein distance to make my code less vulnerable to spelling mistakes. Now I have a need to match strings against simple regular expressions such TV Schedule for \d\d (Jan|Feb|Mar|...). This means that the string TV Schedule for 10 Jan should return 0 while T Schedule for 10. Jan should return 2. This could be done by generating all strings in the regex (in this case 100x12) and find the best match, but that doesn't seam practical. Do you have any ideas how to do this effectively?

    Read the article

  • Using regular expressions to do mass replace in Notepad++

    - by user638820
    I've been trying to replace (and translate) this text, and i don't know what formula I should Use for thousands of places that I need to translate to Spanish. OKay this is what i want to do, i want to use regular expressions on Notepadd++. I give 4 variations, and in bold is what's supposed to go after the name of the place, in lower case and not to be confused with eg. Agency Village because that's its name. Missouri 5,988,927 Adrian City city 1,677 Advance city 1,347 Affton CDP 20,307 Agency Village village 684 Airport Drive village 698 To | [[Adrian City (Misuri)|Adrian City]] || ciudad || 1677 |- | [[Advance (Misuri)|Advance]] || ciudad || 1347 |- | [[Afton (Misuri)|Afton]] || CDP || 20307 |- | [[Agency Village (Misuri)|Agency Village]] || villa || 684 |- | [[Airport Drive (Misuri)|Airport Drive]] || villa || 698

    Read the article

  • Regular Expressions

    - by Rocky
    Hello Everyone, I am new to Stackoverflow and I have a quick question. Let's assume we are given a large number of HTML files (large as in theoretically infinite). How can I use Regular Expressions to extract the list of Phone Numbers from all those files? Explanation/expression will be really appreciated. The Phone numbers can be any of the following formats: (123) 456 7899 (123).456.7899 (123)-456-7899 123-456-7899 123 456 7899 1234567899 Thanks a lot for all your help and have a good one!

    Read the article

  • Python regular expressions assigning to named groups

    - by None
    When you use variables (is that the correct word?) in python regular expressions like this: "blah (?P\w+)" ("value" would be the variable), how could you make the variable's value be the text after "blah " to the end of the line or to a certain character not paying any attention to the actual content of the variable. For example, this is pseudo-code for what I want: >>> import re >>> p = re.compile("say (?P<value>continue_until_text_after_assignment_is_recognized) endsay") >>> m = p.match("say Hello hi yo endsay") >>> m.group('value') 'Hello hi yo' Note: The title is probably not understandable. That is because I didn't know how to say it. Sorry if I caused any confusion.

    Read the article

  • Building 'flat' rather than 'tree' LINQ expressions

    - by Ian Gregory
    I'm using some code (available here on MSDN) to dynamically build LINQ expressions containing multiple OR 'clauses'. The relevant code is var equals = values.Select(value => (Expression)Expression.Equal(valueSelector.Body, Expression.Constant(value, typeof(TValue)))); var body = equals.Aggregate<Expression>((accumulate, equal) => Expression.Or(accumulate, equal)); This generates a LINQ expression that looks something like this: (((((ID = 5) OR (ID = 4)) OR (ID = 3)) OR (ID = 2)) OR (ID = 1)) I'm hitting the recursion limit (100) when using this expression, so I'd like to generate an expression that looks like this: (ID = 5) OR (ID = 4) OR (ID = 3) OR (ID = 2) OR (ID = 1) How would I modify the expression building code to do this?

    Read the article

  • JAVA: Build XML document using XPath expressions

    - by snoe
    I know this isn't really what XPath is for but if I have a HashMap of XPath expressions to values how would I go about building an XML document. I've found dom-4j's DocumentHelper.makeElement(branch, xpath) except it is incapable of creating attributes or indexing. Surely a library exists that can do this? Map xMap = new HashMap(); xMap.put("root/entity/@att", "fooattrib"); xMap.put("root/array[0]/ele/@att", "barattrib"); xMap.put("root/array[0]/ele", "barelement"); xMap.put("root/array[1]/ele", "zoobelement"); would result in: <root> <entity att="fooattrib"/> <array><ele att="barattrib">barelement</ele></array> <array><ele>zoobelement</ele></array> </root>

    Read the article

  • What are block expressions actually good for?

    - by Helper Method
    I just solved the first problem from Project Euler in JavaFX for the fun of it and wondered what block expressions are actually good for? Why are they superior to functions? Is it the because of the narrowed scope? Less to write? Performance? Here's the Euler example. I used a block here but I don't know if it actually makes sense // sums up all number from low to high exclusive which are divisible by a or b function sumDivisibleBy(a: Integer, b: Integer, high: Integer) { def low = if (a <= b) a else b; def sum = { var result = 0; for (i in [low .. <high] where i mod 3 == 0 or i mod 5 == 0) { result += i } result } } Does a block makes sense here?

    Read the article

  • Dealing with regular expressions, Python

    - by Gusto
    I want to remove some symbols from a string using a regular expression, for example: == (that occur both at the beginning and at the end of a line), * (at the beginning of a line ONLY). def some_func(): clean = re.sub(r'= {2,}', '', clean) #Removes 2 or more occurrences of = at the beg and at the end of a line. clean = re.sub(r'^\* {1,}', '', clean) #Removes 1 or more occurrences of * at the beginning of a line. What's wrong with my code? It seems like expressions are wrong. How do I remove a character/symbol if it's at the beginning or at the end of the line (with one or more occurrences)?

    Read the article

  • Regular expressions in python unicode

    - by Remy
    I need to remove all the html tags from a given webpage data. I tried this using regular expressions: import urllib2 import re page = urllib2.urlopen("http://www.frugalrules.com") from bs4 import BeautifulSoup, NavigableString, Comment soup = BeautifulSoup(page) link = soup.find('link', type='application/rss+xml') print link['href'] rss = urllib2.urlopen(link['href']).read() souprss = BeautifulSoup(rss) description_tag = souprss.find_all('description') content_tag = souprss.find_all('content:encoded') print re.sub('<[^>]*>', '', content_tag) But the syntax of the re.sub is: re.sub(pattern, repl, string, count=0) So, I modified the code as (instead of the print statement above): for row in content_tag: print re.sub(ur"<[^>]*>",'',row,re.UNICODE But it gives the following error: Traceback (most recent call last): File "C:\beautifulsoup4-4.3.2\collocation.py", line 20, in <module> print re.sub(ur"<[^>]*>",'',row,re.UNICODE) File "C:\Python27\lib\re.py", line 151, in sub return _compile(pattern, flags).sub(repl, string, count) TypeError: expected string or buffer What am I doing wrong?

    Read the article

  • Mutually exclusive regular expressions

    - by CaptnCraig
    If I have a list of regular expressions, is there an easy way to determine that no two of them will both return a match for the same string? That is, the list is valid if and only if for all strings a maximum of one item in the list will match the entire string. It seems like this will be very hard (maybe impossible?) to prove definitively, but I can't seem to find any work on the subject. The reason I ask is that I am working on a tokenizer that accepts regexes, and I would like to ensure only one token at a time can match the head of the input.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >