Search Results

Search found 6715 results on 269 pages for 'preg match'.

Page 120/269 | < Previous Page | 116 117 118 119 120 121 122 123 124 125 126 127  | Next Page >

  • Regular Expression Routes in Rails

    - by Kevin Sylvestre
    I am looking to create a rails route that is capable of accepting requests using a regular expression. Specifically, I need optional paths. As an example: "(/first)?(/second)?" Would match: /first /second /first/second But not: /second/first Is this possible? Thanks.

    Read the article

  • ActionScript JPGEncoder +bad quality of the image

    - by Alex
    I have noticed that the quality of the images produced by the JPEGEncoder does not match that of other encoders available (i.e. php's built in image compression functions from the gd library) Any explanation ? or hints/workarounds for improving the quality of compressed images by JPEGEncoder ??

    Read the article

  • Using eachDirMatch to skip .svn folders

    - by algernon
    I'm writing a program which needs to traverse a set of directories. Tried to use the following code: file.eachDirMatch(/.*[^.svn]/){ //some code here } But that ended up match none of my directories. I realize this boils down figuring out the right regex hang head in shame but even after revisiting some Java Regular Expression documentation I thought this should work.

    Read the article

  • dropping characters from regular expression groups

    - by tcurdt
    The goal: I want to convert a number from the format "10.234,56" to "10234.56" Using this simple approach almost gets us there /([\d\.]+),(\d\d)/ => '\1.\2' The problem is that the first group of the match (of course) still contains the '.' character. So questions are: Is it possible to exclude a character from the group somehow? How would you solve this with a single regexp (I know this is a trivial problem when not using a single regexp)

    Read the article

  • login not working when changing from mysql to mysqli

    - by user1438647
    I have a code below where it logs a teacher in by matching it's username and password in the database, if correct, then log in, if incorrect, then display a message. <?php session_start(); $username="xxx"; $password="xxx"; $database="mobile_app"; $link = mysqli_connect('localhost',$username,$password); mysqli_select_db($link, $database) or die( "Unable to select database"); foreach (array('teacherusername','teacherpassword') as $varname) { $$varname = (isset($_POST[$varname])) ? $_POST[$varname] : ''; } ?> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" id="teachLoginForm"> <p>Username</p><p><input type="text" name="teacherusername" /></p> <!-- Enter Teacher Username--> <p>Password</p><p><input type="password" name="teacherpassword" /></p> <!-- Enter Teacher Password--> <p><input id="loginSubmit" type="submit" value="Login" name="submit" /></p> </form> <?php if (isset($_POST['submit'])) { $query = " SELECT * FROM Teacher t WHERE (t.TeacherUsername = '".mysqli_real_escape_string($teacherusername)."') AND (t.TeacherPassword = '".mysqli_real_escape_string($teacherpassword)."') "; $result = mysqli_query($link, $query); $num = mysqli_num_rows($result); $loged = false; while($row = mysqli_fetch_array($result)) { if ($_POST['teacherusername'] == ($row['TeacherUsername']) && $_POST['teacherpassword'] == ($row['TeacherPassword'])) { $loged = true; } $_SESSION['teacherforename'] = $row['TeacherForename']; $_SESSION['teachersurname'] = $row['TeacherSurname']; $_SESSION['teacherusername'] = $row['TeacherUsername']; } if ($loged == true){ header( 'Location: menu.php' ) ; }else{ echo "The Username or Password that you Entered is not Valid. Try Entering it Again."; } mysqli_close($link); } ?> Now the problem is that even if the teacher has entered in the correct username and password, it still doesn't let the teacher log in. When the code above was the old mysql() code, it worked fine as teacher was able to login when username and password match, but when trying to change the code into mysqli then it causes login to not work even though username and password match. What am I doing wrong?

    Read the article

  • IIS7 URL Redirect with Regex

    - by andyjv
    I'm preparing for a major overhaul of our shopping cart, which is going to completely change how the urls are structured. For what its worth, this is for Magento 1.7. An example URL would be: {domain}/item/sub-domain/sub-sub-domain-5-16-7-16-/8083770?plpver=98&categid=1027&prodid=8090&origin=keyword and redirect it to {domain}/catalogsearch/result/?q=8083710 My web.config is: <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Magento Required" stopProcessing="false"> <match url=".*" ignoreCase="false" /> <conditions> <add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php" /> </rule> <rule name="Item Redirect" stopProcessing="true"> <match url="^item/([_\-a-zA-Z0-9]+)/([_\-a-zA-Z0-9]+)/([_\-a-zA-Z0-9]+)(\?.*)" /> <action type="Redirect" url="catalogsearch/result/?q={R:3}" appendQueryString="true" redirectType="Permanent" /> <conditions trackAllCaptures="true"> </conditions> </rule> </rules> </rewrite> <httpProtocol allowKeepAlive="false" /> <caching enabled="false" /> <urlCompression doDynamicCompression="true" /> </system.webServer> </configuration> Right now it seems the redirect is completely ignored, even though in the IIS GUI the sample url passes the regex test. Is there a better way to redirect or is there something wrong with my web.config?

    Read the article

  • Data extract from website URL

    - by user2522395
    From this below script I am able to extract all links of particular website, But i need to know how I can generate data from extracted links especially like eMail, Phone number if its there Please help how i will modify the existing script and get the result or if you have full sample script please provide me. Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click 'url must be in this format: http://www.example.com/ Dim aList As ArrayList = Spider("http://www.qatarliving.com", 1) For Each url As String In aList lstUrls.Items.Add(url) Next End Sub Private Function Spider(ByVal url As String, ByVal depth As Integer) As ArrayList 'aReturn is used to hold the list of urls Dim aReturn As New ArrayList 'aStart is used to hold the new urls to be checked Dim aStart As ArrayList = GrabUrls(url) 'temp array to hold data being passed to new arrays Dim aTemp As ArrayList 'aNew is used to hold new urls before being passed to aStart Dim aNew As New ArrayList 'add the first batch of urls aReturn.AddRange(aStart) 'if depth is 0 then only return 1 page If depth < 1 Then Return aReturn 'loops through the levels of urls For i = 1 To depth 'grabs the urls from each url in aStart For Each tUrl As String In aStart 'grabs the urls and returns non-duplicates aTemp = GrabUrls(tUrl, aReturn, aNew) 'add the urls to be check to aNew aNew.AddRange(aTemp) Next 'swap urls to aStart to be checked aStart = aNew 'add the urls to the main list aReturn.AddRange(aNew) 'clear the temp array aNew = New ArrayList Next Return aReturn End Function Private Overloads Function GrabUrls(ByVal url As String) As ArrayList 'will hold the urls to be returned Dim aReturn As New ArrayList Try 'regex string used: thanks google Dim strRegex As String = "<a.*?href=""(.*?)"".*?>(.*?)</a>" 'i used a webclient to get the source 'web requests might be faster Dim wc As New WebClient 'put the source into a string Dim strSource As String = wc.DownloadString(url) Dim HrefRegex As New Regex(strRegex, RegexOptions.IgnoreCase Or RegexOptions.Compiled) 'parse the urls from the source Dim HrefMatch As Match = HrefRegex.Match(strSource) 'used later to get the base domain without subdirectories or pages Dim BaseUrl As New Uri(url) 'while there are urls While HrefMatch.Success = True 'loop through the matches Dim sUrl As String = HrefMatch.Groups(1).Value 'if it's a page or sub directory with no base url (domain) If Not sUrl.Contains("http://") AndAlso Not sUrl.Contains("www") Then 'add the domain plus the page Dim tURi As New Uri(BaseUrl, sUrl) sUrl = tURi.ToString End If 'if it's not already in the list then add it If Not aReturn.Contains(sUrl) Then aReturn.Add(sUrl) 'go to the next url HrefMatch = HrefMatch.NextMatch End While Catch ex As Exception 'catch ex here. I left it blank while debugging End Try Return aReturn End Function Private Overloads Function GrabUrls(ByVal url As String, ByRef aReturn As ArrayList, ByRef aNew As ArrayList) As ArrayList 'overloads function to check duplicates in aNew and aReturn 'temp url arraylist Dim tUrls As ArrayList = GrabUrls(url) 'used to return the list Dim tReturn As New ArrayList 'check each item to see if it exists, so not to grab the urls again For Each item As String In tUrls If Not aReturn.Contains(item) AndAlso Not aNew.Contains(item) Then tReturn.Add(item) End If Next Return tReturn End Function

    Read the article

  • Formatting currency within a specific precision range

    - by Alex Prose
    I am trying to format currency that will always contain 2 decimal digits, but if there are extra digits of accuracy to display up to five. As an example: for value = 5.0 display: $5.00 for value = 5.023 display: $5.023 for value = 5.333333333333333 display: $5.33333 I have been playing with the .ToString() formatting, but I can't seem to find the right match of options. Clarification: I want to show from 2-5 decimals, truncating zeros after the second digit. for value = 5.000000000000000 display: $5.00 for value = 5.333333333333333 display: $5.33333

    Read the article

  • Routing error in rails

    - by user662503
    In my controller I have def update_project_dates p "It is end date....." @user=User.find(params[:user]) @projects=Project.find_all_by_user_id(@user) end In the view page (only some part of the code is copied and pasted) eventDrop: function() { $.ajax({ url:'/update_project_dates/', success:function(data) { alert("Hello"); } }) }, In my routes.rb I have mentioned match '/update_project_dates' => 'users#update_project_dates', :method=> :get get 'update_project_dates' But When the ajax request goes, I get the routing error as Routing Error uninitialized constant UsersController Where am I doing wrong here...Please help..

    Read the article

  • How Would you Mimic an Arbitrary Directory Structure with Rails Routes?

    - by viatropos
    I want to be able to map Google Docs' folder system to urls in my application and am just wondering how I can say "route, I want you to match an arbitrary set of nodes, and the last one is the file (or possibly a directory, I can check in the controller)". So I could do things like: www.mysite.com/documents/folder1/childfolderA/document www.mysite.com/documents/root-level-doc Can the routes.rb file do something like this?

    Read the article

  • Determine if a number is a prime with regex?

    - by kitlite
    I found the following code example for Java on RosettaCode: public static boolean prime(int n) { return !new String(new char[n]).matches(".?|(..+?)\\1+"); } I don't know Java in particular but understand all aspects of this snippet except for the regex itself I have basic to basic-advanced knowledge of Regex as you find it in the built-in PHP functions How does .?|(..+?)\\1+ match prime numbers?

    Read the article

  • Search images using c# in local images folder

    - by np
    We have a images folder which has about a million images in it. We need to write a program which would fetch the image based upon a keyword that is entered by the user. We need to match the file names while searching to find the right image. Looking for any suggestions. Thanks N

    Read the article

  • How do I make an object a property of a model in Ruby on Rails?

    - by iTake
    I have this in my schema: create_table "robots_matches", :force => true do |t| t.integer "robot_id" t.integer "match_id" and I think I want to be able to load a robot and match from within my robots_match model so I can do something like this: robots_match.find(:id).get_robot().Name My attempt in the robots_matches model was this: def get_robot Robot.find(this.id) end I am super new to rails, so feel free to correct my architectural decision here.

    Read the article

  • finding elements with text using jQuery

    - by Tim Sheiner
    I want to create an array of all the html elements within a div that contain text strings, such as <p>some string</p>. I don't want to get hold of the strings, I want the array items to be the elements (in the example, would be the p node). I do not know before hand what the strings will be, so I can't look for string values to match. I also don't want empty text nodes to end up in the array. Thanks!

    Read the article

  • Matching part of website with a regexp.

    - by richardverbruggen
    With a cURL request I load a complete website into a variable: $buffer. In the source of the site there are two labels in between which my relevant content is placed. ****** bunch of code ******* <!-- InstanceBeginEditable name="Kopij" --> this part I want to store in a match <!-- InstanceEndEditable --> ****** bunch of code ******* I've been messing around with preg_match and its regexp. Can someone try to help me? Thanx in advance.

    Read the article

< Previous Page | 116 117 118 119 120 121 122 123 124 125 126 127  | Next Page >