269 Topics

Member Avatar for
Member Avatar for Safia Abdalla

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 …

0
84
Member Avatar for RoyalElite96

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 …

Member Avatar for RoyalElite96
0
202
Member Avatar for joejoe92

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 …

Member Avatar for joejoe92
0
135
Member Avatar for Peter_TARAS

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 …

Member Avatar for Gribouillis
0
161
Member Avatar for Safia Abdalla

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 …

Member Avatar for griswolf
0
12K
Member Avatar for killerpopiller

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: …

Member Avatar for killerpopiller
0
239
Member Avatar for Awesomeness

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 …

Member Avatar for masijade
0
94
Member Avatar for luke noob

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 …

Member Avatar for luke noob
0
615
Member Avatar for stereomatching

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 += …

Member Avatar for stereomatching
0
147
Member Avatar for crazy_perl

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 …

Member Avatar for sysadm1n
0
84
Member Avatar for Setvir

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) …

Member Avatar for Setvir
0
160
Member Avatar for knan

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, …

Member Avatar for TrustyTony
0
199
Member Avatar for Bombshock

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 …

Member Avatar for TrustyTony
0
213
Member Avatar for sowmiya.aariya

[CODE=php] $file=file("templates/index.html"); $rcontent=join("",$file); preg_replace("/{{(.*?)}}/e","$$1",$rcontent); //explain this regular expression statement alone print $rcontent; [/CODE]

Member Avatar for pritaeas
0
59
Member Avatar for madawa123

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 …

Member Avatar for nick.crane
0
82
Member Avatar for gishi

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 …

Member Avatar for Gribouillis
0
223
Member Avatar for mihu

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 …

Member Avatar for mihu
0
144
Member Avatar for nkinar

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. …

Member Avatar for ptmcg
0
540
Member Avatar for steveh000

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 …

Member Avatar for adams161
0
87
Member Avatar for koduruabhinav

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 …

Member Avatar for koduruabhinav
0
228
Member Avatar for jamesvick

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 …

Member Avatar for jamesvick
0
157
Member Avatar for sphynx_25

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 …

Member Avatar for sphynx_25
0
2K
Member Avatar for thenixx

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] …

Member Avatar for FlashCreations
0
105
Member Avatar for mitchems

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 …

Member Avatar for d5e5
1
168
Member Avatar for koveras vehcna

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 …

Member Avatar for griswolf
0
241
Member Avatar for steveh000

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 …

Member Avatar for steveh000
0
110
Member Avatar for farhan386

I have a string contains sequences of 0 and 1. I need to replace all zero sequences whose length less than 5, into number 1 with same length. The zero sequences with length 5 or more should be left as is. For example source : 11000001100010011000001 result : 11000001111111111000001 [CODE] …

Member Avatar for farhan386
0
172
Member Avatar for koveras vehcna

Hello everyone, I am currently working on text processing with Python and I want to parse a .txt file into its sentences as a whole. I tried to create some regular expressions but I failed to do so. I only managed to come up with a regex that splits each …

Member Avatar for TrustyTony
0
1K
Member Avatar for ajithperuva

Hi, I need to retrieve anchor tag innerHTML using RegExp in php. Consider I have a syntax like [CODE] <div class="detailsGray"> <span class="detailEmail"> <a href="http://example.com"class="fontLink">examples@mail.com</a></span> </div> [/CODE] here how can we retrieve [email]examples@mail.com[/email] using RegExp and preg_match_all(). Thanks

Member Avatar for martin5211
0
87
Member Avatar for AuburnMathTutor

I have noticed a few questions popping up from time to time on the subject of formal languages in general, and on regular languages in particular. As I'm pretty bored and enjoy the study of formal languages to a reasonable extent, I thought I might try to give a quick-and-dirty …

Member Avatar for AuburnMathTutor
-1
183

The End.