1,034 Topics
![]() | |
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 | |
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> </TD><TD>Full, Gen. 3 </TD> <TD> </TD> … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … ![]() | |
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 … | |
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. | |
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 | |
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 … | |
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 … | |
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 … | |
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" … | |
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 … | |
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? | |
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 … | |
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 … | |
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 … | |
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 … | |
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 += … | |
[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.*; … | |
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/ … | |
<label class="leftlabel">Name:</label> <div> Steve Peters </div> how towrite REGEX pattern to search Name and its value Steve Peters please help | |
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; … | |
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 … | |
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); … | |
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 … | |
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 … | |
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 … | |
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) … | |
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) { … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 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 … |
The End.