Search Results

Search found 4071 results on 163 pages for 'preg split'.

Page 1/163 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Is there a way to pass another parameter in the preg_replace_callback callback function?

    - by DaNieL
    mmmh guys, i really hope my english is good enaught to explain what i need. Lets take this example (that is just an example!) of code: class Something(){ public function Lower($string){ return strtolower($string); } } class Foo{ public $something; public $reg; public $string; public function __construct($reg, $string, $something){ $this->something = $something; $this->reg = $reg; $this->string = $string; } public function Replace(){ return preg_replace_callback($this->reg, 'Foo::Bar', $this->string); } public static function Bar($matches){ /* * [...] * do something with $matches and create the $output variable * [...] */ /* * I know is really useless in this example, but i need to have an istance to an object here * (in this example, the Something object, but can be something else!) */ return $this->something->Lower($output); } } $s = new Something(); $foo = new Foo($myregexp, $mystring, $s); $content = $foo->Replace(); So, the php manual say that to use a class method as callback in preg_replace_callback(), the method must be abstract. I need to pass an instance of a previuosly initialized object (in the example, an instance of the Something class) at the callback function. I tryed to use call_user_func(), but doesnt work (becose in this way i miss the matches parameter). Is there a way to do that, or have i to separate the process (doing before preg_match_all, for each match retrieve the replace value, and then a simple preg_replace)?

    Read the article

  • How do I get preg replace to work when the url contains a hashtag

    - by Steven
    I found a function online for turning a url within a string into a clickable link. However, when the url contains a hashtag it doesn't work. eg. http://www.bbc.co.uk/radio1/photos/fearnecotton/5759/1#gallery5759 Here's the part of the function concerned: $ret = preg_replace( "#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret ); $ret = preg_replace( "#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret ); Any ideas? thanks

    Read the article

  • Java .split() Method To Split XML Parameters

    - by Buzz Lightyear
    I have this line from an XML document: <?xml version="1.0" encoding="UTF-8"?> <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" contentScriptType="text/ecmascript" width="1024" zoomAndPan="magnify" contentStyleType="text/css" viewBox="0 0 1024 768" height="768" preserveAspectRatio="xMidYMid meet" version="1.0"> I want to be able to split it up, using the split method. For example i want to save each parameter into a String array. So i'd like: contentScriptType="text/ecmascript" width="1024" zoomAndPan="magnify" contentStyleType="text/css" viewBox="0 0 1024 768" height="768" etc etc to be saved into a string array, is there anyway to do this using the split method, or can anybody suggest an easier, more efficient way to do this?

    Read the article

  • Make one monitor act like two, split in half

    - by Nathan J. Brauer
    Context: Ubuntu 11.10, Unity Let's say I have a screen at resolution 1000x500. What I'd like to do is split the screen down the middle so [Unity or X or ?] acts as if there are two displays (each of 500x500). Examples: Unity will display a different toolbar (the top one) on each side of the display. If I maximize a window on the left side of the screen, it will fill the left side only. If I maximize on the right, it will fill the right. If I hit "fullscreen" in youtube (flash) or Chrome or Movie Player, it will only fill the side of the display that it's on. If it's really is impossible to do this with Unity, will it work with Gnome3 and how? A million thanks!

    Read the article

  • Using the vim split command from the command line to get 4 quater splits

    - by sixtyfootersdude
    I want to open four vim files on the command line: vim file1 file2 file3 But I would like each file to be opened in a separate split: vim -c "split file1" -c "split file2" -c "split file3" file4 (The above splits the screen horizontally 4 times) Ideally what I would like to do is split the screen into 4 squares like: |-------|-------| | | | | | | |-------|-------| | | | | | | |-------|-------| I know how to do this once vim is open but I am unable to do this from the command line (using vs). Any ideas? Everything I try ends up looking like this (or a different variation): |-------|-------| | | | |-------| | | | | |-------| | | | | | | | |-------|-------|

    Read the article

  • split large text file without missing data record

    - by Santosh
    I have a 140 MB text file, which contains detail information of books in library. For each book details there is a standard format data details in text file. I need to parse it and insert the data in Database. Here, parsing text file is not an issue. I am facing problem in parsing this large file. So i decided to split the file in small file around 2 MB each file. But i can't manually split this large file in so many pieces. I got HJsplit tool, which split the file but this also doesn't helped as this split the file but 1 book details half part is in one file and rest part is in second file. so if i split this way then information will be missed. How to split the large so that i cant miss the information ? Is there any tool which help me in this condition.

    Read the article

  • php preg replace

    - by David
    I'm trying to build a PHP preg replace string when processing poorly written xml, such that if I am given: $x='<abc x="y"><def x="g">more test</def x="g"><blah>test data</blah></abc x="y">'; That it checks if there's a space within a closing tag and deletes everything from the space to the end of the tag such that. becomes <abc x="y"><def x="g">more test</def><blah>test data</blah></abc> thanks

    Read the article

  • SQL Server Split() Function

    - by HighAltitudeCoder
    Title goes here   Ever wanted a dbo.Split() function, but not had the time to debug it completely?  Let me guess - you are probably working on a stored procedure with 50 or more parameters; two or three of them are parameters of differing types, while the other 47 or so all of the same type (id1, id2, id3, id4, id5...).  Worse, you've found several other similar stored procedures with the ONLY DIFFERENCE being the number of like parameters taped to the end of the parameter list. If this is the situation you find yourself in now, you may be wondering, "why am I working with three different copies of what is basically the same stored procedure, and why am I having to maintain changes in three different places?  Can't I have one stored procedure that accomplishes the job of all three? My answer to you: YES!  Here is the Split() function I've created.    /******************************************************************************                                       Split.sql   ******************************************************************************/ /******************************************************************************   Split a delimited string into sub-components and return them as a table.   Parameter 1: Input string which is to be split into parts. Parameter 2: Delimiter which determines the split points in input string. Works with space or spaces as delimiter. Split() is apostrophe-safe.   SYNTAX: SELECT * FROM Split('Dvorak,Debussy,Chopin,Holst', ',') SELECT * FROM Split('Denver|Seattle|San Diego|New York', '|') SELECT * FROM Split('Denver is the super-awesomest city of them all.', ' ')   ******************************************************************************/ USE AdventureWorks GO   IF EXISTS       (SELECT *       FROM sysobjects       WHERE xtype = 'TF'       AND name = 'Split'       ) BEGIN       DROP FUNCTION Split END GO   CREATE FUNCTION Split (       @InputString                  VARCHAR(8000),       @Delimiter                    VARCHAR(50) )   RETURNS @Items TABLE (       Item                          VARCHAR(8000) )   AS BEGIN       IF @Delimiter = ' '       BEGIN             SET @Delimiter = ','             SET @InputString = REPLACE(@InputString, ' ', @Delimiter)       END         IF (@Delimiter IS NULL OR @Delimiter = '')             SET @Delimiter = ','   --INSERT INTO @Items VALUES (@Delimiter) -- Diagnostic --INSERT INTO @Items VALUES (@InputString) -- Diagnostic         DECLARE @Item                 VARCHAR(8000)       DECLARE @ItemList       VARCHAR(8000)       DECLARE @DelimIndex     INT         SET @ItemList = @InputString       SET @DelimIndex = CHARINDEX(@Delimiter, @ItemList, 0)       WHILE (@DelimIndex != 0)       BEGIN             SET @Item = SUBSTRING(@ItemList, 0, @DelimIndex)             INSERT INTO @Items VALUES (@Item)               -- Set @ItemList = @ItemList minus one less item             SET @ItemList = SUBSTRING(@ItemList, @DelimIndex+1, LEN(@ItemList)-@DelimIndex)             SET @DelimIndex = CHARINDEX(@Delimiter, @ItemList, 0)       END -- End WHILE         IF @Item IS NOT NULL -- At least one delimiter was encountered in @InputString       BEGIN             SET @Item = @ItemList             INSERT INTO @Items VALUES (@Item)       END         -- No delimiters were encountered in @InputString, so just return @InputString       ELSE INSERT INTO @Items VALUES (@InputString)         RETURN   END -- End Function GO   ---- Set Permissions --GRANT SELECT ON Split TO UserRole1 --GRANT SELECT ON Split TO UserRole2 --GO   The syntax is basically as follows: SELECT <fields> FROM Table 1 JOIN Table 2 ON ... JOIN Table 3 ON ... WHERE LOGICAL CONDITION A AND LOGICAL CONDITION B AND LOGICAL CONDITION C AND TABLE2.Id IN (SELECT * FROM Split(@IdList, ',')) @IdList is a parameter passed into the stored procedure, and the comma (',') is the delimiter you have chosen to split the parameter list on. You can also use it like this: SELECT <fields> FROM Table 1 JOIN Table 2 ON ... JOIN Table 3 ON ... WHERE LOGICAL CONDITION A AND LOGICAL CONDITION B AND LOGICAL CONDITION C HAVING COUNT(SELECT * FROM Split(@IdList, ',') Similarly, it can be used in other aggregate functions at run-time: SELECT MIN(SELECT * FROM Split(@IdList, ','), <fields> FROM Table 1 JOIN Table 2 ON ... JOIN Table 3 ON ... WHERE LOGICAL CONDITION A AND LOGICAL CONDITION B AND LOGICAL CONDITION C GROUP BY <fields> Now that I've (hopefully effectively) explained the benefits to using this function and implementing it in one or more of your database objects, let me warn you of a caveat that you are likely to encounter.  You may have a team member who waits until the right moment to ask you a pointed question: "Doesn't this function just do the same thing as using the IN function?  Why didn't you just use that instead?  In other words, why bother with this function?" What's happening is, one or more team members has failed to understand the reason for implementing this kind of function in the first place.  (Note: this is THE MOST IMPORTANT ASPECT OF THIS POST). Allow me to outline a few pros to implementing this function, so you may effectively parry this question.  Touche. 1) Code consolidation.  You don't have to maintain what is basically the same code and logic, but with varying numbers of the same parameter in several SQL objects.  I'm not going to go into the cons related to using this function, because the afore mentioned team member is probably more than adept at pointing these out.  Remember, the real positive contribution is ou are decreasing the liklihood that your team fails to update all (x) duplicate copies of what are basically the same stored procedure, and so on...  This is the classic downside to duplicate code.  It is a virus, and you should kill it. You might be better off rejecting your team member's question, and responding with your own: "Would you rather maintain the same logic in multiple different stored procedures, and hope that the team doesn't forget to always update all of them at the same time?".  In his head, he might be thinking "yes, I would like to maintain several different copies of the same stored procedure", although you probably will not get such a direct response.  2) Added flexibility - you can use the Split function elsewhere, and for splitting your data in different ways.  Plus, you can use any kind of delimiter you wish.  How can you know today the ways in which you might want to examine your data tomorrow?  Segue to my next point. 3) Because the function takes a delimiter parameter, you can split the data in any number of ways.  This greatly increases the utility of such a function and enables your team to work with the data in a variety of different ways in the future.  You can split on a single char, symbol, word, or group of words.  You can split on spaces.  (The list goes on... test it out). Finally, you can dynamically define the behavior of a stored procedure (or other SQL object) at run time, through the use of this function.  Rather than have several objects that accomplish almost the same thing, why not have only one instead?

    Read the article

  • A maximum character limit on the preg functions?

    - by animuson
    On my site I use output buffering to grab all the output and then run it through a process function before sending it out to the browser (I don't replace anything, just break it into more manageable pieces). In this particular case, there is a massive amount of output because it is listing out a label for every country in the database (around 240 countries). The problem is that in full, my preg_match functions seems to get skipped over, it does absolutely nothing and returns no matches. However, if I remove parts of the labels (no particular part, just random pieces to reduce characters) then the preg_match functions works again. It doesn't seem to matter what I remove from the label, it just seems to be that as long as I remove so many characters. Is there some sort of cap on what the preg functions can handle or will it time out if there is too much data to be scanned over?

    Read the article

  • Javascript Split: without losing character

    - by Rohan
    I want to split certain text using JavaSscript. The text looks like: 9:30 pm The user did action A. 10:30 pm Welcome, user John Doe. 11:30 am Messaged user John Doe Now, I want to split the string into events. i.e.: 9:30 pm The user did action A. would be one event. I'm using RegEx for this: var split = journals.split(/\d*\d:/); Thing is, the first two characters are getting lost. The split appears like this: 30 pm The user did action A. How do I split so that the split maintains the first two/three characters (ie 9: or 10:) etc? Thanks!

    Read the article

  • Split with token info

    - by boomhauer
    I would like to split a string using multiple chars to split upon. For example, consider spin text format: This is a {long|ugly|example} string I would want to parse this string and split it on the "{", "|", and "}" chars myString.Split('|','{','}') Now I have tokens to play with, but what I would like is to retain the info about which char was used to split each piece of the array that is returned. Any existing code that can do something like this?

    Read the article

  • PHP: Rawurlencode inside Preg-replace

    - by elmaso
    Hello, I have this snippet while($row = mysql_fetch_array($result)){ $search = '' . $row['searchquery']; echo '<a href="http://www.example.com/' . preg_replace( array('/[^\s\w]/','/\s/'),array('','+'),$search) . '+/">' ... but if someone types in äöü, it doesnt show the letters - with rawurlencode thats possible, but I want to remove the blank spaces with pregreplace and replace it with + is that possible?

    Read the article

  • Preg Expression to identify classes/ids in a CSS file that have no contents

    - by dclowd9901
    I'm in the process of updating some old CSS files in our systems, and we have a bunch that have lots of empty classes simply taking up space in the file. I'd love to learn how to write Regular expressions, but I just don't get them. I'm hoping the more I expose myself to them (with a little more cohesive explanation), the more I'll end up understanding them. The Problem That said, I'm looking for an expression that will identify text followed by a '{' (some have spaces in between, and some do not) and if there are no letters or numbers between that bracket and '}' (spaces don't count), it will be identified as a matching string. I suppose I can trim the whitespace out of the doc before I run a regular expression through it, but I don't want to change the basic structure of the text. I'm hoping to return it into a large <textarea>. Bonus points for explaining the characters and their meanings, and also an expression identifying lines in the copy without any text or numbers, as well. I will likely use the final expression in PHP script. tl;dr: Regular Expression to match: .a_class_or #an_id { /* if there aren't any alphanumerics in here, this should be a matching line of text */ }

    Read the article

  • in php how do I use preg replace to turn a url into a tinyurl

    - by Steven
    I need to convert a string of text containing a long url into the same string but with a tinyurl (using the tinyurl api). eg. convert "blah blah blah /http://example.com/news/sport blah blah blah" into "blah blah blah http://tinyurl.com/yaeocnv blah blah blah". How can it be done? PLEASE NOTE I added a slash before the long url as I'm only allowed to post one link

    Read the article

  • preg replace h2 tags with spaces [closed]

    - by fire
    Possible Duplicate: PHP Regular express to remove <h1> tags (and their content) I have some HTML that looks like this: <h2> Fund Management</h2> <p> The majority of property investments are now made via our Funds.</p> Trying to use a regular expression to strip h2 tags but doesn't work because of the space between the opening and closing h2 tags. preg_replace('/<h2>(.+?)<\/h2>/', '', $content); Any ideas on how to make this work? Also I would ideally like it to replace h1-h6 tags so maybe it needs [1-6] or something?

    Read the article

  • split command on Ubuntu command-line

    - by pedro
    I want to split a file into multiple files with at most 25 lines each. I'm using this: split -l 25 /etc/adduser.conf > /home/ubuntu/PL/trab3/rc_ But I do not get the files I expect. How can I get files with filenames like rc_01, rc_02, etc.?

    Read the article

  • split shell command

    - by pedro
    I want split a file into multiple files with at most 25 lines each. I'm using this: split -l 25 /etc/adduser.conf /home/ubuntu/PL/trab3/rc_ But I do not get the files I expect. How can files with the filenames like rc_01, rc_02, etc.?

    Read the article

  • Trouble printing to local printer when connected to VPN with split-tunneling enabled

    - by Marve
    I'm a volunteer network admin for a multi-tenant non-profit office space. One of our new tenants uses a VPN to connect to remote resources using RRAS and Small Business Server 2008. They also have a local network printer for the workstations in our office. When connected to the VPN, they cannot print to the local printer. I informed their network admin that they need to enable split-tunneling to fix this. Their network admin enabled split-tunneling, but apparently printing still didn't work. He told me that I need to open port 1723 on our office firewall to allow it to work. I'm just a novice administrator and not familiar with RRAS, but this doesn't sound right to me and I haven't been able to find anything on the web to validate it. Additionally, my understanding of split-tunneling is that it is handled entirely by the VPN client and should work irrespective of firewall settings. Is my understanding of the situation incorrect? What steps should I take to resolve this problem?

    Read the article

  • Open a buffer as a vertical split in VIM

    - by alfredodeza
    If you are editing a file in VIM and then you need to open an existing buffer (e.g. from your buffer list: :buffers) how can you open it in a vertical split? I know that you already can open it with a normal split like: :sbuffer N Wehere N is the buffer number you want, however, the above opens that N buffer horizontally, not vertically. I'm also aware that you can change the window placement after opening and have a Vertical Split like so: Ctrl-W H Ctrl-W L Which will vertically split the window to the right or the left. It seems to me that if there is a sbuffer there should be a vsbuffer but that doesn't exist (not that I am aware of) Also, please note that I am not looking for a plugin to solve this question. I know about a wealth of plugins that will allow you to do this. I am sure I might be missing something that is already there. EDIT: In the best spirit of collaboration, I have created a simple Function with a Mapping if someone else stumbles across this issue and do not want to install a plugin: Function: " Vertical Split Buffer Function function VerticalSplitBuffer(buffer) execute "vert belowright sb" a:buffer endfunction Mapping: " Vertical Split Buffer Mapping command -nargs=1 Vbuffer call VerticalSplitBuffer(<f-args>) This accomplishes the task of opening a buffer in a right split, so for buffer 1, you would call it like: :Vbuffer 1

    Read the article

  • Firewalling a Cisco ASA Split tunnel

    - by dunxd
    I have a Cisco ASA 5510 at head office, and Cisco ASA 5505 in remote offices. The remote offices are connected over a split tunnelled VPN - the ASA 5505s use "Easy VPN" Client type VPN in Network Extension Mode (NEM). I'd like to set firewall rules for the non-tunnelled traffic only. Traffic over the VPN to head office should not have any firewall rules applied. I might want to apply different firewall rules to different remote offices. All the documentation I have been able to find assumes the Client VPN is a software endpoint, and all the configuration is done at the 5510. When using a Cisco 5505 as the VPN client, is it possible to configure any firewalling at the Client end, or does it all have to come from the 5510? Are there any other issues to look out for when split-tunnelling a VPN by this method?

    Read the article

  • Python: Split, strip, and join in one line

    - by PandemoniumSyndicate
    I'm curious if their is some python magic I may not know to accomplish a bit of frivolity given the line: csvData.append(','.join([line.split(":").strip() for x in L])) I'm attempting to split a line on :, trim whitespace around it, and join on , problem is, since the array is returned from line.split(":"), the for x in L #<== L doesn't exist! causes issues since I have no name for the array returned by line.split(":") So I'm curious if there is a sexy piece of syntax I could use to accomplish this in one shot? Cheers!

    Read the article

  • How to split this string in c#?

    - by melaos
    hi i'm really not used to the split string method in c# and i was wondering how come there's no split by more than one char function? and my attempt to try to split this string below using regex has just ended up in frustration. anybody can help me? basically i want to split the string below down to aa**aa**bb**dd^__^a2a**a2a**b2b**dd^__^ into aa**aa**bb**dd a2a**a2a**b2b**dd and then later into aa aa bb dd a2a a2a b2b dd thanks!

    Read the article

  • how to club the data split by split function

    - by udaya
    Hi my data is dat1; the split statement is var splitstr = dat1.split("-"); I have splited the data from this format 2010 -02-02 to Element 0 = 2010 Element 1 = 05 Element 2 = 22 this format..Using split function, i want to arrange that like 2010,02,02 how can i do that

    Read the article

  • Split Internet Explorer into Dual-Panes

    - by Asian Angel
    If you have a wide screen monitor then you may want to make better use of Internet Explorer’s browser window area. Now you can split the browser window into dual-panes as needed with the IE Split browser plugin. Note: Requires .NET Framework 2.0 or higher (link provided below). IE Split in Action If you are using an older version of this software here is something to keep in mind before upgrading to the 2.0 release. Once you have installed IE Split you will notice a new toolbar added to your browser. As seen here, you can condense it down tightly and access it using the drop-down bar. A closer look at the drop-down bar. Notice the address bar…this will be for the left pane when you split the browser window. Here is our browser split into dual-panes. There are two address bars and two tab/title bars each corresponding to their appropriate pane. It may look slightly backwards at first but is not hard to get used to. A better view of the left pane with the IE Split navigation & title bars showing. Note: The title bar can be hidden if desired. And the right pane. You can also have multiple “split” tabs open if needed. There is nothing quite like getting double the value for the same amount of space. When you no longer need dual-panes open just click on the “x” to close IE Split down. All back to normal again. Conclusion While might not be for everyone this can still be useful for those who need side-by-side access to websites without using multiple separate windows. Links Download IE-Split Download the Microsoft .NET Framework 4 (Standalone Installer) Similar Articles Productive Geek Tips Set Up Multi-Pane Viewing in FirefoxWhy Can’t I Turn the Details/Preview Panes On or Off in Windows Vista Explorer?Split a text file in half (or any percentage) on Ubuntu LinuxMysticgeek Blog: A Look at Internet Explorer 8 Beta 1 on Windows XPMake Ctrl+Tab in Internet Explorer 7 Use Most Recent Order TouchFreeze Alternative in AutoHotkey The Icy Undertow Desktop Windows Home Server – Backup to LAN The Clear & Clean Desktop Use This Bookmarklet to Easily Get Albums Use AutoHotkey to Assign a Hotkey to a Specific Window Latest Software Reviews Tinyhacker Random Tips Xobni Plus for Outlook All My Movies 5.9 CloudBerry Online Backup 1.5 for Windows Home Server Snagit 10 Filevo is a Cool File Hosting & Sharing Site Get a free copy of WinUtilities Pro 2010 World Cup Schedule Boot Snooze – Reboot and then Standby or Hibernate Customize Everything Related to Dates, Times, Currency and Measurement in Windows 7 Google Earth replacement Icon (Icons we like)

    Read the article

  • Python: Split by 1 or more occurrences of a delimiter

    - by Adam Matan
    Hi, I have a formatted string from a log file, which looks like: >>> a="test result" That is, the test and the result are split by some spaces - it was probably created using formatted string which gave test some constant spacing. Simple splitting won't do the trick: >>> a.split(" ") ['test', '', '', '', ... '', '', '', '', '', '', '', '', '', '', '', 'result'] split(DELIMITER, COUNT) cleared some unnecessary values: >>> a.split(" ",1) ['test', ' result'] This helped - but of course, I really need: ['test', 'result'] I can use split() followed by map + strip(), but I wondered if there is a more Pythonic way to do it. Thanks, Adam

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >