306 Topics
| |
Hey guys, I need to be able to get a certain value out of the following. [code] Job# : 442254 Contact : TO BE ADVISED Model : BZ500 50GN02630 Purchase Order/Your Reference : Contract Type: C3 CopyPlan - Contract Minimum Job Type: H Audit, Admin, Housekeeping Fault/Problem(s) reported: CHECK SENTINEL … | |
Hello, I am currently passing some HTML through to preg_match and I want to access all the HTML between two tags, however as the same tags may be repeated afterwards my current expression isn't working. For example, my expression at the moment is [code]<li>(.*)</li>[/code] But as the HTML is like … | |
I was curious about the workings of extracting URLs fro webpages. I did several searches for this subject online, and discovered that some people preferred using regular expression while others preferred using parsers. I would like to ask the Daniweb community what they prefer. If you prefer a regular expression … | |
Hi, I do know a bit PHP and also had no probles with regular expressions, [I]until now[/I]. This is my code: [CODE] $string = ereg_replace("([\"](.*)[\"])", "<span class=\"style10\">\\2</span>", $sting);[/CODE] . Why doesn't it work? It all runs fine when using: [CODE] $string = ereg_replace("([*](.*)[*])", "<span class=\"style10\">\\2</span>", $sting);[/CODE] , but I want … | |
Hi, I'm trying to create a piece of code which joins a line that matches a string, and the next succeeding line (no matter what this line contains). I'm getting confused at what Regular Expression (RE) to use. So far I have: [CODE] input1 = open("out.txt","r") output1 = open("outp.txt","w") with … | |
Hi, I try to read line by line from a file some data. Each line in that file has the following format: x = 78.36734693877551, z = 11.428571428571429 -> amplitude: 8.62847057093655E-6 | phase -1.5707968246742405\n I am trying to extract those four float numbers using regular expression. I came with the … | |
I am working on this program in Python that would allow me to scan for a certain phrase in a certain text document. I used the finditer function in Python's re library.The certain line of code resembled the following: [CODE]phrase=regex.finditer(page)[/CODE] I also had a print statement at the end that … | |
Problem with storing extracted values in SQLite - How to adress or index list of values for proper insertion into table. The Regex works fine: input logging data looks like: 0.0.0(06026104) 1.6.1(0.1501)(1011111000) 1.6.1*32(0.1446)(1010190800) 1.8.1(02484.825) 1.8.1*32(02449.574) correct regex output: 06026104 0.1501 02484.796 [CODE] with open("usage.log") as fp: for line in fp: … | |
I want to remove all the spaces, carriage returns, and "comments" (the text inside the <>'s) from this document: I tried the regular expression [ICODE]( )|(\n)(|<.*>)[/ICODE], but that removes everything but the [ICODE]-1[/ICODE] at the end. It doesn't do that if I remove the [ICODE]|(<.*>)[/ICODE], but then it doesn't remove … | |
i have a field in my database with numbers like this....... ,27,,277,,4277,,677,,678,,6688,,8754,,123478, each number was updated (added) like this .. ,27, all numbers updated are unique, when i try to match ,27, i get ,27, ,277, ,4277, not just ,27, my code is like this... [code=php] $id = 27 $string … | |
Hello, I'm totally out of luck with creating a working patternt to match for my preg_match. What I would like to do is, create a pattern that will match sentenses in a bunch of text.. It should recognize a word that has a capital letter and take it as the … | |
Below is my code [code] string str2 = "1, 2, 3, 4, 5, 6, 7, 8"; string output; typedef std::tr1::sregex_token_iterator sti; const sti end; for(sti i(str2.begin(), str2.end(), regex(",\\s"), -1); i != end; ++i) { //output += "\"" + *i + "\", "; output += "\""; output += *i; output += … | |
I have a code which parses/validates all the fields present in i/p weblog file. My first field is ip_address & currently can have a value like 12.45.24.245 Now I have a change where ip_address can be a dummy value something like $10.00 or $23.123.34. or $12.233. How should I change … | |
Anyone have an idea what the regex would be for preg_split to split a string at a semicolon ([icode];[/icode]), but ignore any quoted (single or double) parts as well as ignore escaped ([icode]\;[/icode]) semicolons? I have tried to decipher this one and could not (regex not my strongpoint - YET) … | |
I have a file named test.txt I get the file [CODE]file=open("test.txt","r") obj=file.read() file.close() print obj a=a b=b c=c d=e e=d e=f f=e f=g g=h[/CODE] All I want to do with this obj is that, I've to create a regular expression such that, 1.If the left number matches the right number, … | |
Heya Daniweb, I've been working on Regular Expressions, thanks to cghtkh who told me about them. I've used resources from: [URL="Newthinktank.com"]NewThinkTank.com[/URL] [URL="http://docs.python.org/library/re.html"]Python Regular Expression Documentation[/URL] and [URL="daniweb.com"]Daniweb.com[/URL]! I figured I'd share my code, ask a few questions, and get some feedback on what I did if I can. Feedback helps … | |
[CODE=php] $file=file("templates/index.html"); $rcontent=join("",$file); preg_replace("/{{(.*?)}}/e","$$1",$rcontent); //explain this regular expression statement alone print $rcontent; [/CODE] | |
Hi guys , I have a number format like nn.nn.nn and nn.nn. I want to write a regex t check either one of them exist or not. I wrote this [CODE]^(\d\d).(\d\d)$[/CODE] but it only applies to nn.nn. Since i'm not ood in regex. i couldnt think a way to check … | |
Hi Everyone, Do you know how i can get the values using Regular Expression between the opening and closing tags of xml files? I need to process xml files using python and i just need to get the values between tags. For example: [CODE]<name value>my name is </name value>[/CODE] i … | |
Hallo everybody, Can someone help me with some regexs for testing : - in a textbox , i need to test only string carachters , not numbers,digits, spaces; - in a textbox , i want to text only numbers, not strings, char..other. Please.. Pattern patternForInfo = Pattern.compile("[a-zA-Z]", Pattern.CASE_INSENSITIVE); Pattern patternForNumere … | |
I have a string in Python that is comprised of code in C/C++ syntax. I would like to use regular expressions to search through this string and replace an expression of the form 'pow(a,b)' with 'a^b' I've attempted to do this, but my code does not seem to be working. … | |
Hi Guys I am really green when it comes to regex , I have never had to use it much but here goes, I want to be able to remove html tags from a string so I am only left with the content. i am using [CODE] String.replaceAll("<(.|\n)*?>","");[/CODE] This doesnt … | |
Hi, I have two files and each consists of modules and in turn modules consists of some verilog data and instances.i have to search for module name in the two files and comapare the contents of the modules in the two files. i have code it does module search,extract the … | |
i want to implement this feature : if i have a following sentence : {my name is james vick and iam a {member|user|visitor} on this {forum|website|site} and iam loving it | iam admin and iam a {supervisor|admin|moderator} on this {forum|website|site} and iam loving it} on a click of button i … | |
Hey everyone, (Hopefully) a rather quick question. I'm currently trying to use regex to search a string for the location of the longest continuous match in a string where the *same* character keeps repeating. It doesn't matter which character it is, as long it is the highest number of consecutive … | |
Hello people, I'm trying to collect some data stored between <body> and </body> tags inside a string. Here's a piece of the code i'm using: [CODE] $regex = '/<body>(.*?)<\/body>/si'; preg_match($regex, $content, $content); $content = $content[0];[/CODE] This works perfect, except that it also includes the above mentioned tags. I would just … | |
Hello! I am fairly new to regular expressions (in PHP in particular, since there seem to be some special requirements/restrictions), and am especially stumped with my most recent attempt at parsing two particular strings. The first one is a URL in which I want to retrieve the first variable: [code]http://somesite.come/page.html?var=1234&some=2[/code] … | |
I thought it might be useful to show the special local matching variables that perl uses. Here they are: $1..$9 Contains the subpattern from the corresponding set of parentheses in the last pattern matched like \1..\9 $& Contains the string matched by the last pattern match $` The string preceding … | |
Hello everyone, I am currently working on a code and I got stuck in a part. My algorithm is a text generator that operates on project Gutenberg and its flow is like this: Enter a sentence as input 1-Pick longest word of input sentence 2-Search the longest word of the … | |
Hi Guys I wonder if you can help me get my head around this. I am trying to search a String for a sub string but there are not gaps in the original string for example [code] String s1 = "www.google.com/search/" String s2 = "google" [/code] when i attempt to … |
The End.