in Education by
I have an HTML page that contains some filenames that i want to download from a webserver. I need to read these filenames in order to create a list that will be passed to my web application that downloads the file from the server. These filenames have some extention. I have digged about this topic but havn't fount anything except - Regex cannt be used to parse HTML. Use HTML Agility Pack Is there no other way so that i can search for text that have pattern like filename.ext from an HTML file? Sample HTML that contains filename -

<![if !supportLists]> 1.      <![endif]>**13572_PostAccountingReport_2009-06-03.acc**

I cant use HTML Agility Pack because I m not allowed to download and make use of any application or tool. Cant this be achieved by anyother logic? This is what i have done so far string pageSource = ""; string geturl = @"C:\Documents and Settings\NASD_Download.mht"; WebRequest getRequest = WebRequest.Create(geturl); WebResponse getResponse = getRequest.GetResponse(); using (StreamReader sr = new StreamReader(getResponse.GetResponseStream())) { pageSource = sr.ReadToEnd(); pageSource.Replace("=", ""); } var fileNames = from Match m in Regex.Matches(pageSource, @"[0-9]+_+[A-Za-z]+_+[0-9]+-+[0-9]+-+[0-9]+.+[a-z]") select m.Value; foreach (var s in fileNames) Response.Write(s); Bcause of some "=" occuring in every file name i m not able to get the filename. how can I remove the occurrence of "=" in pageSource string Thanks in advance Akhil JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Well, knowing that regex aren't ideal to find values in HTML: var files = []; var p = document.getElementsByTagName('p'); for (var i = 0; i < p.length; i++){ var match = p[i].innerHTML.match(/\s(\S+\.ext)\s/) if (match) files.push(match[1]); } Live DEMO Note: Read the comments to the question. If the extension can be anything, you can use this: var files = []; var p = document.getElementsByTagName('p'); for (var i = 0; i < p.length; i++){ var match = p[i].innerHTML.match(/\b(\S+\.\S+)\b/) console.log(match) if (match) files.push(match[1]); } document.getElementById('result').innerHTML = files + ""; But this really really not reliable. Live DEMO

Related questions

0 votes
    how can you insert some other html text file into your one html file? write the tag used for this purpose? Select the correct answer from above options...
asked Nov 28, 2021 in Education by JackTerrance
0 votes
    I have a task coming up where I have to manually enter an HKEY_USER key value and string value for ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    which section is used for text and tags that are shown directly on your web page? A head B body. c title. d HTML Select the correct answer from above options...
asked Dec 27, 2021 in Education by JackTerrance
0 votes
    which section is used for text and tags that are shown directly on your web page? A head B body. c title. d HTML Select the correct answer from above options...
asked Dec 26, 2021 in Education by JackTerrance
0 votes
    I am pulling information from a Page note from the Facebook API. In the output I get an image URL ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    I am pulling information from a Page note from the Facebook API. In the output I get an image URL ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    Which of the following is used to extract data from HTML code of websites? (a) Webscraping (b) ... questions and answers pdf, Data Science interview questions for beginners...
asked Oct 29, 2021 in Education by JackTerrance
0 votes
    The sample xml file is shown below What should I write in XSLT so that i can get the sample ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    I am refactoring some CSS on a website. I have been working on, and noticed the absence of traditional ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    I am refactoring some CSS on a website. I have been working on, and noticed the absence of traditional ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    a) Harshita wants to create an HTML form. Which tag should she use to create this form? Her teacher has asked ... plz answer this fast Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    My code is about bookStore with list of books. I need to extract all data(books) from a JSON file and put them in a ... console.log(e); } } function bookToHTMLRow(book) { return `...
asked May 14, 2022 in Education by JackTerrance
0 votes
    can anyone help me.. [NSString stringWithFormat:@"document.getElementsByTagName('body')[0].style.textAlign = ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    .controller('LoginCtrl', function($scope, $rootScope, $http, $state) { window.localStorage.removeItem("loggedIn"); ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    How can we take input text from user in HTML page? (a) input tag (b) inoutBufferedReader tag (c) meta ... & Servlet of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
...