Jump to content

Search the Community

Showing results for tags 'regex'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hello, i have small problem with replacing croatian letters. I am using jQuery, and am trying to replace croatian letters č,ć,š,đ,ž but dunno how to put this in regex. For now i have regex for all chars: $('#text').replace(/\b[a-z]/g, 'somechars' ); Unfortunately it wont reconize croatian special letters. Thanks. Regards
  2. Hello Everyone, I have a log file in txt format. Here's a part of it: ================================================ [Jan 25 2012 11:47:31] - ID2PDF v.2.6 (ID2PDF.jsx) General options: [default] (ID2PDF_options.xml) ================================================ Loaded options from XML file: '/Thisis/some/Users/sumuser/Desktop/SM_Folder/ESQ/Virtual_Proof_ESQ/processing/ID2PDF_options.xml extendedPrintPDF started Postfix '3.0' was append from file 'ESQ030112ELAM_lo-metadata.xml' for file: '/Thisis/some/Users/sumuser/Desktop/SM_Folder/ESQ/Virtual_Proof_ESQ/processing/someFile.indd printPDF started PDF Export Preset: Some preset PDF file created: ''/Thisis/some/Users/sumuser/Desktop/SM_Folder/ESQ/Virtual_Proof_ESQ/processing/someFile.pdf'. File someFileName.xml removed postprocessingDocument started INDD file removed: '/Thisis/some/Users/sumuser/Desktop/SM_Folder/ESQ/Virtual_Proof_ESQ/processing/someFile.indd ================================================ [Jan 25 2012 15:18:23] - ID2PDF v.2.6 (ID2PDF.jsx) General options: [default] (ID2PDF_options.xml) ================================================ Loaded options from XML file: ''/Thisis/some/Users/sumuser/Desktop/SM_Folder/COS/Contract_Proof_COS/processing/ID2PDF_options.xml extendedPrintPDF started Postfix '8.1' was append from file 'ESQ030112Politics_Russia_lo-metadata.xml' for file: '/Thisis/some/Users/sumuser/Desktop/SM_Folder/COS/Contract_Proof_COS/processing/oneMoreFile.indd printPDF started PDF Export Preset: Hearst PDF 1.6_1_16_08 PDF file created: '/Thisis/some/Users/sumuser/Desktop/SM_Folder/COS/Contract_Proof_COS/processing/oneMoreFile.pdf'. File oneMoreFile.xml removed postprocessingDocument started INDD file removed: /Thisis/some/Users/sumuser/Desktop/SM_Folder/COS/Contract_Proof_COS/processing/oneMoreFile.indd And it continues this way. I am supposed to catch the 3 letter words like ESQ and COS (appearing in the path of file on very first line of entry ONLY) in an array. I'm not able to think of a logic/create a RegEx because the user name may change often. Can anyone give me heads up on how I could possibly achieve this? Would appreciate the help. Thanks
  3. I'm trying to create an auto linking functionality, The problem I have is that when a keyword has been linked or the text already contains a link then the title or text attributes of the anchor tag may get replaced. So I don't want any anchor tag to be used in the match. I'm using a random keyword replacement so its not a case of just consecutively replacing them. Here is the function I'm currently using: function replace_n_occurences ($str, $search, $replace, $n) { $foundRKW = 'na'; $replace = getRandomRelatedURL( $search, $foundRKW ); // Get all occurences of $search and their offsets within the string $count = preg_match_all('/\b'.preg_quote($search, '/').'\b/', $str, $matches, PREG_OFFSET_CAPTURE); // Get string length information so we can account for replacement strings that are of a different length to the search string $searchLen = strlen($search); $diff = strlen($replace) - $searchLen; $offset = 0; // Loop $n random matches and replace them, if $n < 1 || $n > $count, replace all matches $toReplace = ($n < 1 || $n > $count) ? array_keys($matches[0]) : (array) array_rand($matches[0], $n); foreach ($toReplace as $match) { $str = substr($str, 0, $matches[0][$match][1] + $offset).$replace.substr($str, $matches[0][$match][1] + $searchLen + $offset); $offset += $diff; } return $str; }
  4. I need to find valid records as part of a database cleanup script. What I need is a regular expression that will match, for a single column: records containing BOTH numbers AND letters (or any other character). records containing ONLY numbers (including decimals) Invalid records are those which contain ONLY letters and I do not want these returned, or NULL for the column. Anybody good with regex?
  5. absfrm

    Using Regex

    I have a question to use regex in PHP. i have a string in murkup.and wanna to convert it to html. These are my strings: 1. "Text Link":http://site.com It want to be a html link with url after : and before "space" at the end, and link's text is string between the quotations 2. !http://site.com/picture.gif! It want to be a html img tag: <img src='link between "!" characters' /> 3. *.my text It want to be an item in html tag : <li>mytext after "*." and before "enter" (new line)</li> or etc. how can i do it? i try many solutions in regex but not worked right. Thanks
  6. This is the first part of the search script and i was doing some debuging and i cant figure out why this code if( !($fd = fopen($url,"r")) ){ die( "Could not open URL!" ); } while( $buf = fgets($fd,1024) ) { /* Remove whitespace from beginning and end of string: */ $buf = trim($buf); /* Try to remove all HTML-tags: */ $buf = strip_tags($buf); $buf = preg_replace('/&\w;/', '', $buf); /* Extract all words matching the regexp from the current line: */ preg_match_all("/(\b[\w+]+\b)/",$buf,$words); print_r($words); } doubles each associate array like this Array ( [0] => Array ( ) [1] => Array ( ) ) Array ( [0] => Array ( [0] => It [1] = > was [2] => November ) [1] => Array ( [0] => It [1] = > was [2] => November ) ) When I would expect this Array ( [0] => Array ( ) ) Array ( [0] => Array ( [0] => It [1] = > was [2] => November ) )
  7. Freaks, My goal is trying to edit the code below so, no matter what, everything gets sent to the Index controller: so, for example: http://domain.tld/page would go to the Index Controller, and call the pageAction method. right now, that would get sent to the page controller... Yaf_Dispatcher::getInstance()->getRouter()->addRoute( "pages", new Yaf_Route_Regex( "#^/index/page/(\d+)#", array('controller' => "Index"), array(1 => "page") ) ); I'm horrible with regular expressions. I'm pretty sure I could just edit #^/index/page/(\d+)# (and remove the 2nd part of the array) and it will just work. Any help would be greatly appreciated! There is a bit of info here about it: http://php.net/manual/en/yaf-route-rewrite.construct.php THANK YOU!
  8. Regex always kills me. I want a string to be only letters, numbers, dash, underscore, or space. if ( !preg_match( $pattern, $str ) ){ $err = 'Only letters, numbers, space, underscore and dash are allowed.'; return $err } In this example, what is $pattern ? My best guess was... $pattern = '/[^a-zA-Z0-9_-\s]+/'; ... but it's not working.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.