1,034 Topics

Member Avatar for
Member Avatar for Joe34

How can I get some part of $B to be only [B]auto[/B](The first word in $A[1])? [CODE] if(preg_match('/^(.*)">(.*)/',$A[1],$B) == 1) { die($B[1]); } [/CODE] $A[1] is.... [B]auto[/B]">auto</a>, <a href="automobile">automobile</a>, <a href="motorcar">motorcar</a>, <a href="machine">machine</a></div><div class=Rel><a hr .................................... /tr><tr><td><a href="zw

Member Avatar for smantscheff
0
167
Member Avatar for nonshatter

Howdy, I have a basic html file containing certain data I need to extract. This is the code for just one of the tables on the page: [CODE]<TABLE title="Left Magazine"class="dataTable" align="center" cellspacing="0" cellpadding="0"> <caption>Media Details</caption><THEAD><TR class="captionRow"><TH>Slot #</TH><TH>Attn</TH><TH>Status</TH><TH>In Drive</TH><TH>Label</TH><TH>Media Loads</TH><TH>Comment</TH></TR></THEAD> <TBODY> <TR class="altRowColor" > <TD>1 </TD> <TD>&nbsp;</TD><TD>Full, Gen. 3 </TD> <TD>&nbsp;</TD> …

Member Avatar for Ezzaral
0
210
Member Avatar for jaango123

Hi all, Could you please let us know the best way to do the below validation in xslt we are reading card number using an xpath expression <xsl:value of select ="/*/*/*/cardnumber" /> from input. It is a string of 19 characters. we would like to include a check which will …

Member Avatar for iceandrews
0
134
Member Avatar for ihatehippies

I'm having a hard time getting my website to email the contents of form. It will send an email with the field labels but no values.. ie name: phone number: email: from: () the only thing I can get it to return is the ip Here is the relevant html …

0
66
Member Avatar for benjie987

Hi. I'm trying to create a 'search engine' like program. With a bit of searching i found this website which was relevant to what i needed to do.[url]http://www.dreamincode.net/code/snippet1278.htm[/url] [CODE] if (Regex.IsMatch(allRead, regMatch))//If the match is found in allRead { Console.WriteLine("found\n"); Console.WriteLine(regMatch); Console.Read(); }[/CODE] I thought "console.writeline(regmatch)" would display the related …

Member Avatar for Momerath
0
309
Member Avatar for phplover

Hi, I have a password reset form and a user can enter either there username or email in one text box. One problem i am having is with validating the data. I have a username regex function that works fine to validate username and uses php's inbuilt FILTER_VALIDATE_EMAIL. Basically when …

Member Avatar for phplover
0
705
Member Avatar for ben_

I wrote this function about a year ago, it's very useful for generating safe file or folder names from text that a user inputs. One method I use this for is storing the filename in the database and then url-rewriting with global.asax. You can get an example of url rewriting …

Member Avatar for Momerath
0
4K
Member Avatar for techeee

Hi Regex gurus, I was developing a asp.net application. I need to validate my email field. I already searched a lot in the web but didn't found any suitable regex for my situation.I need to fulfill the belows criteria 1)Shouldn't allow a user to enter numeric data only. i.e, it …

Member Avatar for Pgmer
0
162
Member Avatar for braj1999

I am facing a similar problem where we have to compare two strings. I applied the regex to match it and it works fine for the string which dont have space between. However in case the matching string containg space, then its failing. Please let me know how to tackle …

Member Avatar for b1izzard
0
61
Member Avatar for dips255

I have the following code that converts text in querystring to an image. This is giving image with white background. Need help to get a transparent background. [code] <%@ Page Language="VB" ContentType="image/gif" Debug="true" Explicit="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Import Namespace="System.Drawing.Imaging" %> <%@ Import Namespace="System.IO" %> <script runat="server"> Protected …

Member Avatar for questpond
0
293
Member Avatar for zizuno

I have been told by a number of people to use xpath instead of regex for some of my regex searches. What advantages does xpath provide over regex? I can't find a webpage that says that. Been through over 10 pages of search so far.

Member Avatar for richieking
0
614
Member Avatar for Neversleepin

Hi, here i just try to delete the content in text file between S and e letter. but i don't know to write the ReplaceAll() methode after this [CODE]String[] paras = Pattern.compile("^(S)(.*)(e)$").split(inputText);[/CODE] How could i use ReplaceAll() here? Thank you

Member Avatar for Neversleepin
0
139
Member Avatar for Neversleepin

Hi, i'm trying to use regex to delete lines which starts with a letter or a number. for example: if i have a text file with many lines and i want to delete every lines which starts with S and 2. What operator do i have to use? i tried …

Member Avatar for Neversleepin
0
2K
Member Avatar for killerpopiller

Hi, I can connect to an energy-meter (Baudrate 300!) and the logfile with 228 lines comes slowly in.[code=Python]line = ser.readline(eol='!') print line [/code] If I use the above code, the complete logfiles is shown. And if I parse separatly saved logfiles with match, it sorts out the right values into …

0
127
Member Avatar for judithSampathwa

hi there, i have been asking this question every time. [CODE] public bool ValidateTelNo(string TelNo) { bool value = false; string rePhoneNumber = @"[1-9]\d{2}\s?\d{3}\d{4}$"; string PhoneNoFormat = @"\([1-9]\d{2}\)\s?\d{3}\-\d{4}$"; Regex re = new Regex(rePhoneNumber); Regex re1 = new Regex(PhoneNoFormat); if (re.IsMatch(TelNo) || (re1.IsMatch(TelNo))) value = true; else value = false; return …

Member Avatar for kvprajapati
0
111
Member Avatar for JannuBl22t

Hey! I have a problem with C# regex. Can you please tell me how I can match anchor: Atm I have it like this: [CODE]Regex.Match(pagecontent, @"<a (.*) href=" + url + "(.*)>(.*?)</a>");[/CODE] but some how it doesnt want to work for [CODE]<a target="_blank" href="http://myurl.com">Title</a>[/CODE] And I need to get "Title" …

Member Avatar for Ketsuekiame
0
139
Member Avatar for Jinspire

Hello, everyone! I have a the following regular expression validator: [CODE]<asp:RegularExpressionValidator ID="revTime" runat="server" ControlToValidate="txtTime" ErrorMessage="Time interval must be between 00:00 and 23:59" ValidationExpression="(^0{0,1}\d:[0-5]\d{0,1}$)|(^[0,1]\d:[0-5]\d(0,1)$)|(^2[0-3]:[0-5]\d(0,1)$)" Display="Dynamic" />[/CODE] The validator WORKS. The regular expression works too. Problem is, the message does not display. I've tried the following: * Changing the Display attribute to …

Member Avatar for Jinspire
0
105
Member Avatar for Joe34

For example here is some code..... [CODE] preg_match_all("/<a(?:[^>]*)href=\"([^\"]*)\"(?:[^>]*)>(?:[^<]*)<\/a>/is", $stripped_file, $matches);[/CODE] What I don't get is all of those special characters? (?:[^>]*) How can I do this with the h1 tag, h2 tag, and h3 tag?

Member Avatar for blocblue
0
478
Member Avatar for mnmo88

Hi guys, this is the first time for me to post something, i'm really a big fan of the site and so far every time i get stuck in something at uni i come to here. so thanks for helping me survive so far. anywho, i'm here because i need …

Member Avatar for mnmo88
0
145
Member Avatar for jrhitokiri

I am trying to get Domain names/URLs from the title and description in ebay, but the text varies a lot. Note that the url/domain names are limited to *.com, *.net, *.info, etc. For instance, I'd have to parse through text such as: IPAD SCREEN LENS.COM 3 4 5 Letter LLLL …

Member Avatar for jrhitokiri
0
127
Member Avatar for moone009

Hello! Basically I need this program to go line by line down my text file and tell me if it sees "000-00-0000"......we use this as a dummy number otherwise the file wont process. Right now the program will tell me it sees "000-00-0000" in the file but a few lines …

Member Avatar for Mitja Bonca
0
5K
Member Avatar for DoctorGiraffe

Hello! Yes, This is my first post. And it might seem a little selfish that i just joined to ask a question, so don't worry, i'm not gonna ask and run, i'll stick around. So my problem, what im trying to do is using regex i'm pulling information from a …

Member Avatar for codeorder
0
991
Member Avatar for tchiloh

i try to open iexplorer without to login. but it likes that the cookie is not saved. how can i solve this problem? thit is my code: [CODE] public class Web1 { private string URL = "http://test.nl"; private CookieContainer cook = new CookieContainer(); public void eerst(string RedmineURL) { URL += …

0
57
Member Avatar for wailoon88

[CODE]import java.awt.BorderLayout; import java.awt.Cursor; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.BufferedReader; import java.io.FileWriter; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.FileReader; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.io.FileReader; import java.util.*; …

Member Avatar for peter_budo
0
245
Member Avatar for Xcelled194

Hi, I'm writing a web crawling program for my personal site, and I'm looking at using regex to extract the URLs. However, I have both absolute and relative URLs, and I want to match URLs only on my site (mysite.com). So it would match: [CODE]/index.php image1.jpg page1.html Http://mysite.com/ Http://mysite.com/page1.html Http://Wiki.mysite.com/ …

Member Avatar for Xcelled194
0
107
Member Avatar for omokop

<label class="leftlabel">Name:</label> <div> Steve Peters </div> how towrite REGEX pattern to search Name and its value Steve Peters please help

Member Avatar for kvprajapati
0
58
Member Avatar for shajis001

Syntax Highlighting Code [code] private void richTextBox1_TextChanged(object sender, EventArgs e) { string tokens = "(auto|double|int|struct|break|else|long|switch|case|enum|register|typedef|char|extern|return|union|const|float|short|unsigned|continue|for|signed|void|default|goto|sizeof|volatile|do|double|if|static|while)"; Regex rex = new Regex(tokens); MatchCollection mc = rex.Matches(richTextBox1.Text); int StartCursorPosition = richTextBox1.SelectionStart; foreach (Match m in mc) { int startIndex = m.Index; int StopIndex = m.Length; richTextBox1.Select(startIndex, StopIndex); richTextBox1.SelectionColor = Color.Red; richTextBox1.SelectionStart = StartCursorPosition; …

Member Avatar for mcriscolo
0
132
Member Avatar for weloki

I'm working on scraping HTML pages and transforming the selected content from them into XML and I've been seeing a few errors here and there thrown by the Saxon XSLT parser: WARN [2011-01-07 14:44:35 EST] (SaxonTranslator#429473) improper java log: XPTY0004: A sequence of more than one item is not allowed …

Member Avatar for iceandrews
0
842
Member Avatar for hussainiat

function tempdbentry() { var regex=/^[0-9A-Za-z]+$/; //^[a-zA-z]+$/ var myname = document.ItemEntryForm.iname.value; var mycat = document.ItemEntryForm.selectcat.value; var mypic = document.ItemEntryForm.ipic.value; "<?php $phpmyname = '?><script language=javascript>document.write(myname);</script><?php'; $phpmyname = str_replace('?>', '', $phpmyname); ?>" "<?php $phpmycat = '?><script language=javascript>document.write(mycat);</script><?php'; $phpmycat = str_replace('?>', '', $phpmycat); ?>" "<?php $phpmypic = '?><script language=javascript>document.write(mypic);</script><?php'; $phpmypic = str_replace('?>', '', $phpmypic); …

Member Avatar for Airshow
0
1K
Member Avatar for matt_platts

Im trying to use a regular expression backreference to reference a hash key. Here's an example of the non working code so you can see what I'm trying to achieve (I hope!): [CODE] $str="String of text containing item1 and item2"; $x['item1']="Item 1"; $x['item2']="Item 2"; $str=preg_replace("/item1/","$x[\${1}1]",$str); print $str; [/CODE] I want …

Member Avatar for matt_platts
0
139
Member Avatar for andyhunter

Stuck on trying to limit a persons name to say 20 characters in a string or a phone number to 6 characters in a string, i cant get the {} inside or after regex to work with either a minimium or maximium number so that in my loop if a …

Member Avatar for aspire1
0
93
Member Avatar for MisterSnrub

My form has a RegularExpressionValidator that validates user input in a textbox, lik so: [CODE] <asp:TextBox ID="taSSN" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="revSSN" runat="server" ControlToValidate="taSSN" ValidationExpression="^\d{3}-\d{2}-\d{4}$"> Invalid! Remember, you MUST type in the dashes!! </asp:RegularExpressionValidator> [/CODE] Suppose that that the regular expression I want to validate is the standard U.S. Social Security Number …

0
72
Member Avatar for bob24bob

this is the therapist code- [CODE]import string import regex import whrandom #---------------------------------------------------------------------- # translate: take a string, replace any words found in dict.keys() # with the corresponding dict.values() #---------------------------------------------------------------------- def translate(str,dict): words = string.split(string.lower(str)) keys = dict.keys(); for i in range(0,len(words)): if words[i] in keys: words[i] = dict[words[i]] return string.join(words) …

Member Avatar for TrustyTony
0
187
Member Avatar for judithSampathwa

hi there, i have a code to validate a tel number but the thing is i want it to restrict it for 10 digits. currently i can add any number of digits how can i restrict it to 10 digits the code is below [CODE] public bool ValidateTelNo(string TelNo) { …

Member Avatar for Narue
0
434
Member Avatar for mr_scooby

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 …

Member Avatar for mr_scooby
0
140
Member Avatar for frankvw

Hi, Firstly, I am quite new to python so hopefully this could be quick answer for any kind sole who give help. I am trying to connect the data files created from one piece of equipment to another process that require similar, but not the same, data .txt files. The …

Member Avatar for frankvw
0
103
Member Avatar for etftw

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 …

Member Avatar for pritaeas
0
94
Member Avatar for m_wylie85

Hi all i have writen a bit of code here to read a line of text from a text file and display it depending on what the user searches for which is taken from a text box. but it will only read one line it will not display all the …

Member Avatar for iconoclazt
0
122
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
85
Member Avatar for puvi

hi guys, i have enrolled to for brainbench php certification which is due in another month and half, but i havent prepared specifically for the test yet, till now i have just played around with some codes, done lil bit of trial n error stuff thats it. here is the …

Member Avatar for pauper2thedemon
0
163
Member Avatar for m_wylie85

Hi all trying get small program work. I want my program to search for a word within a text file then out put the word with the rest of the fileds with the sentence. so say i input 4 word/numbers from 4 different text boxes. the ouput to the text …

Member Avatar for sergb
0
133
Member Avatar for terabyte

I was wondering if there is a global matching flag, considering there is a global replacement flag (/g) I'm using this workaround to make multiple matches in a string [CODE] while(!$stop_var) { if($source =~ /(PATTERN)/i) { push(@matches, $1); $source = $'; } else { $stop_var =1; } } [/CODE] is …

Member Avatar for mitchems
0
169
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
207
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
136
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
180
Member Avatar for CGober

Hey guys, I've got a program I've got just about complete but run into an issue regarding pictureboxes. The program scrapes sites for images based on regex patterns the user specifies, then builds a gallery of all the images inside of a flowpanel. When I scroll the flowpanel all of …

0
42
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
244
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
97
Member Avatar for tones1986

I have no good regex experience -- its all pretty new and confusing to me. I understand some of the VERY basics, but to do what im looking for...is way past me! I have the following text i would like to parse, pulling out the highlighted section everytime. Unknown Trap …

Member Avatar for d5e5
0
150

The End.