Search Results

Search found 9447 results on 378 pages for 'str replace'.

Page 9/378 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Using SDL to replace colors using SDL Color Keys

    - by Shawn B
    Hey, I am working an a simple Roguelike game, and using SDL as the display. The Graphics for the game is an image of Codepage 437, with the background being black, and the font white. Instead of using many seperate image files that are already colored, I want to use one image file, and replace the colors when it is being loaded into memory. The code to split the codepage into a sprite sheet works properly, but when attempting to print in color, everything comes out in white. I had it working the past, but somehow I broke the code when changing it from change the color at print, to change the color on load. Here is the code to load the image: SDL_Surface *Screen,*Font[2]; SDL_Rect Character[256]; Uint8 ScreenY,ScreenX; Uint16 PrintX,PrintY,ScreenSizeY,ScreenSizeX; Uint32 Color[2]; void InitDisplay() { if(SDL_Init(SDL_INIT_VIDEO) == -1) { printf("SDL Init failed\n"); return; } ScreenSizeY = 600; ScreenSizeX = 800; Screen = SDL_SetVideoMode(ScreenSizeX,ScreenSizeY,32,SDL_HWSURFACE | SDL_RESIZABLE); SDL_WM_SetCaption("Alpha",NULL); SDL_Surface *Load; Load = IMG_Load("resource/font.png"); Font[0] = SDL_DisplayFormat(Load); SDL_FreeSurface(Load); Color[0] = SDL_MapRGB(Font[0]->format,255,255,255); Color[1] = SDL_MapRGB(Font[0]->format,255,0,0); Uint8 i,j,k = 0; PrintX = 0; PrintY = 0; for(i = 0; i < 16; i++) { for(j = 0; j < 16; j++) { Character[k].x = PrintX; Character[k].y = PrintY; Character[k].w = 8; Character[k].h = 12; k++; PrintX += 8; } PrintX = 0; PrintY += 12; } PrintX = 0; PrintY = 0; for(i = 1; i < 2; i++) { Font[i] = SDL_DisplayFormat(Font[0]); SDL_SetColorKey(Font[i],SDL_SRCCOLORKEY,Color[i]); SDL_FillRect(Font[i],&Font[i]->clip_rect,Color[i]); SDL_BlitSurface(Font[0],NULL,Font[i],NULL); SDL_SetColorKey(Font[0],0,Color[0]); } } The problem is with the last for loop above. I can't figure out why it isn't working. Any help is greatly appreciated!

    Read the article

  • strtok wont accept: char *str

    - by bks
    strtok wont work correctly when using char *str as the first parameter (not the delimiters string). does it have something to do with the area that allocates strings in that notation? (which as far as i know, is a read-only area). thanks in advance example: //char* str ="- This, a sample string."; // <---doesn't work char str[] ="- This, a sample string."; // <---works char delims[] = " "; char * pch; printf ("Splitting string \"%s\" into tokens:\n",str); pch = strtok (str,delims); while (pch != NULL) { printf ("%s\n",pch); pch = strtok (NULL, delims); } return 0;

    Read the article

  • "Invalid use of Null" when using Str() with a Null Recordset field, but Str(Null) works fine

    - by Mike Spross
    I'm banging my head against the wall on this one. I was looking at some old database reporting code written in VB6 and case across this line (the code is moving data from a "source" database into a reporting database): rsTarget!VehYear = Trim(Str(rsSource!VehYear)) When rsSource!VehYear is Null, the above line generates an "Invalid use of Null" run-time error. If I break on the above line and type the following in the Immediate pane: ?rsSource!VehYear It outputs Null. Fine, that makes sense. Next, I try to reproduce the error: ?Str(rsSource!VehYear) I get an "Invalid use of Null" error. However, if I type the following into the Immediate window: ?Str(Null) I don't get an error. It simply outputs Null. If I repeat the same experiment with Trim() instead of Str(), everything works fine. ?Trim(rsSource!VehYear) returns Null, as does ?Trim(Null). No run-time errors. So, my question is, how can Str(rsSource!VehYear) possibly throw an "Invalid use of Null" error when Str(Null) does not, when I know that rsSource!VehYear is equal to Null?

    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

  • Regex one-to-one mapping pattern replace

    - by polygenelubricants
    How would you use regex to write a function that replaces all lowercase letters with uppercase and vice versa? Note: this is NOT a homework question. See also my previous explorations of regex: Regex split into overlapping strings (Alan Moore's answer is especially instructive) Can you use zero-width matching regex in String split? (my solution exploits a known Java regex bug with regards to non-obvious length lookbehind!)

    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

  • replace string in preg_replace

    - by zahir hussain
    <?php $a="php.net s earch for in the all php.net sites this mirror only function list online documentation bug database Site News Archive All Changelogs just pear.php.net just pecl.php.net just talks.php.net general mailing list developer mailing list documentation mailing list What is PHP? PHP is a widely-used..."; ?> I want to highlight specific words. For example php, net and func: php.net s earch for in the all **php**.**net** sites this mirror only **func**tion list online documentation bug database Site News Archive All Changelogs just pear.**php**.**net** just pecl.**php**.**net** just talks.php.net general mailing list developer mailing list documentation mailing list What is **PHP**? **PHP** is a widely-used... Thanks advance.

    Read the article

  • multiline perl search and replace (one-liner)

    - by yaya3
    I want to perform the following vim substitution as a one-liner in the terminal with perl. I would prefer to allow for any occurences of white space and/or new lines, rather than explicitly catering for them as I am below. %s/blockDontForget">\n*\s*<p><span><a\(.*\)<\/span>/blockDontForget"><p><a\1/g I've tried this: perl -pi -e 's/blockDontForget"><p><span><a(.*)<\/span>/blockDontForget"><p><a$1/msg' I presume I am misinterpreting the flags. Where am I going wrong? Thanks. EDIT: The above example is to strip the spans out of the following html: <div class="block blockDontForget"> <p><span><a href="../../../foo/bar/x/x.html">Lorem Ipsum</a></span></p> </div>

    Read the article

  • find and replace values in a flat-file using PHP

    - by peirix
    I'd think there was a question on this already, but I can't find one. Maybe the solution is too easy... Anyway, I have a flat-file and want to let the user change the values based on a name. I've already sorted out creating new name+value-pairs using the fopen('a') mode, using jQuery to send the AJAX call with newValue and newName. But say the content looks like this: host|http:www.stackoverflow.com folder|/questions/ folder2|/users/ And now I want to change the folder value. So I'll send in folder as oldName and /tags/ as newValue. What's the best way to overwrite the value? The order in the list doesn't matter, and the name will always be on the left, followed by a |(pipe), the value and then a new-line. My first thought was to read the list, store it in an array, search all the [0]'s for oldName, then change the [1] that belongs to it, and then write it back to a file. But I feel there is a better way around this? Any ideas? Maybe regex?

    Read the article

  • Replace underscore between words (reg.exp)

    - by lasseespeholt
    Hey, I need a regular expression to solve the following problem (links to similar problems is also appreciated, related tutorials etc.): __some_words_a_b___ => __some words a b___ ____ => ____ So I want underscores between words to be replaced with space and keep leading and trailing underscores. I found this: ^[ \t]+|[ \t]+$ and I guess it most be something like that. I will use it in jQuery, Java (stdlibs) and maybe XSLT. Addition: The sentences do not necessarily start with underscores or ends with underscores. It is also possible that a sentence ain't containing underscores at all. Best regards Lasse Espeholt

    Read the article

  • Replace whitespaces using PHP preg_replace function ignoring quoted strings

    - by Saiful
    Look at the following string: SELECT column1 , column2, column3 FROM table1 WHERE column1 = 'text, "FROM" \'from\\\' x' AND column2 = "sample text 'where' \"where\\\" " AND ( column3 = 5 ) I need to escape unnecessary white space characters from the string like: removing white space from beginning and ending position of , ( ) etc removing newline (\r\n) and tabs (\t) But one thing. The remove process could not remove white spaces from the quoted string like: 'text, "FROM" \'from\\' x' "sample text 'where' \"where\\" " etc. i need to use the PHP function: preg_replace($pattern, $replacement, $string); So what will be the value of $pattern and $replacement where the value of $string is the given SQL.

    Read the article

  • Find and replace certain part of value (jquery)

    - by Hakan
    This might be a little complicated. See code below. When image is clicked I want to change "MY-ID-NUMBER" in "value" and "src" of object. But I want the other information to remain. When link is clicked I want to restore "value" and "src" so I can use the same function for next image that is clicked. Is it possible? Please help! My HTML: <img height="186" width="134" alt="4988" src="i123.jpg"> <img height="186" width="134" alt="4567" src="i124.jpg"> <a class="restore-to-default" href="#">DVD</a> <div class="tdt"> <object width="960" height="540"><param name="movie" value="http://www.domain.com/v3.4/player.swf?file=http://se.player-feed.domain.com/cinema/MY-ID-NUMBER/123-1/><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><embed id="player" name="player" type="application/x-shockwave-flash" src="http://www.player.domain.com/v3.4/player.swf?file=http://se.player-feed.domain.com/cinema/MY-ID-NUMBER/123-1/&display_title=over&menu=true&enable_link=true&default_quality=xxlarge&controlbar=over&autostart=true&backcolor=000000&frontcolor=ffffff&share=0&repeat=always&displayclick=play&volume=80&linktarget=_blank" width="960" height="540"allowFullScreen="true" allowScriptAccess="always"></embed></object> My jquery: $('img').click(function(){ var alt = $(this).attr("alt"); $('.tdt object').val("alt", alt); // Some how change "MY-ID-NUMBER" into the "alt-value" of image }); $('a').click(function(){ //restore to "MY-ID-NUMBER" }); Thanks!

    Read the article

  • Replace a fragment programmatically

    - by Vishal
    I have three fragments as shown in below figure. I have added all these three fragments in LinearLayout using .xml file and when my launcher activity starts I load that .xml layout using setContentView.I have some controls on fragment2. Clicking on any one loads the fragment4 programmatically using FragmentTransaction and commit method. This fragments is added to the screen but the problem is it take the whole screen area. What can be the problem?

    Read the article

  • text replace with regex in sqlserver

    - by Thiyaneshwaran S
    Currently i have sql-server nvarchar(max) column which has text that starts with """ The only thing that varies in the pattern is the < in the class name. The common part is "" Some sample values are "" "" "" All the These span text are present only at the beginning of the column. Any such matching span in the middle should not be removed or matched. Whats the sql server query with regex to remove all these occurance of span?

    Read the article

  • Using preg_replace to replace all occurrences in php

    - by Greg-J
    Regex is absolutely my weak point and this one has me completely stumped. I am building a fairly basic search functionality and I need to be able to alter my user input based on the following pattern: Subject: %22first set%22 %22second set%22-drupal -wordpress Desired output: +"first set" +"second set" -drupal -wordpress I wish I could be more help as I normally like to at least post the solution I have so far, but on this one I'm at a loss. Any help is appreciated. Thank you.

    Read the article

  • Regex to replace 'li' with 'option' without losing class and id attributes

    - by Earthman Web
    I am looking for a solution using preg_replace or similar method to change: <li id="id1" class="authorlist" /> <li id="id2" class="authorlist" /> <li id="id3" class="authorlist" /> to <option id="id1" class="authorlist" /> <option id="id2" class="authorlist" /> <option id="id3" class="authorlist" /> I think I have the pattern correct, but not sure how to do the replacement part... Here is the (wordpress) php code: $string = wp_list_authors( $args ); //returns list as noted above $pattern = '<li ([^>]*)'; $replacement = '?????'; echo preg_replace($pattern, $replacement, $string); Suggestions, please?

    Read the article

  • php search and replace first element in div

    - by cnotethegr8
    i have a structure that looks like this <div class="table"> <div> <p> name1 </p> <p> title1 </p> </div> <div> <p> name2 </p> <p> title2 </p> </div> <div> <p> name3 </p> <p> title3 </p> </div> </div> and it continues a few hundred more times. what can i write in php that will search ( class="table" div ) and add a class to only the first 'p' in each 'div'?

    Read the article

  • Text replace with regex in SQL Server

    - by Thiyaneshwaran S
    Currently I have a SQL server column of type nvarchar(max) which has text that starts with <span class="escape_<<digits>>"></span> The only thing that varies in the pattern is the <<digits>> in the class name. The common part is <span class="myclass_ and the closing </span> Some sample values are <span class="myclass_12"></span> <span class="myclass_234"></span> <span class="myclass_4546"></span> These span text are present only at the beginning of the column. Any such matching span in the middle should not be removed or matched. Whats the SQL Server query with regex to remove all these occurances of span?

    Read the article

  • VIM Replace word with contents of paste buffer?

    - by plong
    I need to do a bunch of word replacements in a file and want to do it with a vi command, not an EX command such as :%s///g. I know that this is the typical way one replaces the word at the current cursor position: cw<text><esc> but is there a way to do this with the contents of the unnamed register as the replacement text and without overwriting the register?

    Read the article

  • Replace a whole line in a txt file

    - by user302935
    I'am new to Python 3 and could really use a little help. I have a txt file containing: InstallPrompt= DisplayLicense= FinishMessage= TargetName=D:\somewhere FriendlyName=something I have a python script that in the end, should change just two lines to: TargetName=D:\new FriendlyName=Big Could anyone help me, please? I have tried to search for it, but I didnt find something I could use. The text that should be replaced could have different length.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >