天道酬勤,学无止境

replace

How to replace following (deprecated) OpenGL functions?

I've got a simple application showing a custom frame buffer (it is sort of an emulator of the frame buffer functionality) using OpenGL: void GLWidget::resizeGL( int w, int h ) { glViewport( 0, 0, w, h ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( 0, w, 0, h, -1, 1 ); } void GLWidget::paintGL() { if( pScreen != 0 ) { glRasterPos2i( 0, 2 * pScreen->height ); glPixelZoom( 2, -2 ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); glDrawPixels( pScreen->width, pScreen->height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pScreen->pixels ); } } Really, this is all I want to do it, no shaders, no fancy

2022-01-19 00:35:15    分类:问答    c++   opengl   deprecated   replace

Java string.replace(old, new) count how many replaced?

I have my console (image down below), and I have a command that will replace all oldstinrg to newstring. But how do I count how many of those were replaced? (If the code replaced only once a to b then it will be 1, but if it replaced a to b twice the value would be 2) (this is just a part of code, but no other part is needed or any how related to this part of code) else if(intext.startsWith("replace ")){ String[] replist = original.split(" +"); String repfrom = replist[1]; String repto = replist[2]; lastorep = repfrom; lasttorep = repto; String outtext = output.getText(); String newtext =

2022-01-18 11:49:27    分类:问答    java   string   replace   command

Greasemonkey script to find rows with certain conditions

I tried some different ways do find rows in a table where a columns contain a particular link. My goal: replace an icon when a link to xyz is in this same row as the image. This is my snippet so far: var rows = document.getElementsByTagName("tr"); for(var i = rows.length - 1; i >= 0; i--) { var links = rows[i].getElementsByTagName("a"); for(var k = links.length - k; k >= 0; k--) { if (links[k].href =="http://www.XXXX.net/forum/index.php?showforum=121"){ var images = rows[i].getElementsByTagName("img"); for (var j=0;j<images.length;j++) { images[j].src = "http://www.XXXX.net/forum/folder_post

2022-01-18 11:30:55    分类:问答    image   replace   hyperlink   greasemonkey

batch code to test if script contains anything other than Letters and Numbers

I was wondering if it is possible to test a variable to see if it contains anything other than Letters and numbers? I need to have this in order to limit username specs. I have a kind of example script below. :top echo enter a name set /p name=">" If contains (Anything other than letters/numbers/dashes) echo Invalid Name. & goto top echo thank you! pause Thanks everyone! Edit: I would think this is probably a duplicate, however I do not know what to search for to find other posts... Whenever I searched anything related to my question it brought up find and replace in text files or something

2022-01-18 11:29:22    分类:问答    string   batch-file   replace

Replace Node Name

Is it possible to replace a nodes name? Like: HTML: <strong id="element">Text</strong> Javascript: var element = document.getElementById("element"); element.nodeName = "b"; As I see it's not working, if it's not possible in this way, then how can it be done? Why I need it: I'm building a Text Editor, and IE uses strong instead of b in the execCommand() function and I would like to change that, I tried to build the execCommand("bold") from scratch but there is a lots of problem and differences even between IE 8 and 9. So now I decided to change it's node name, it would be really easy, but doesn

2022-01-18 11:28:09    分类:问答    javascript   replace   nodename

Literal dollar sign in a regular expression

I am working with Canada (fr-CA) locale and trying to do following: var str = "<dataset >{1}</dataset>"; var temp = "<set Cost x = '1,8M $' />"; str = str.replace(/\{1\}/g, temp); OUTPUT: "<dataset ><set Cost x = '1,8M </dataset>" /></dataset>" DESIRED OUTPUT: "<dataset ><set Cost x = '1,8M $'" /></dataset>" replace function is misunderstanding $' from '1,8M $' as an expression and hence repeating in the output. Any ideas/workaround? Thank you for your time.

2022-01-18 09:38:38    分类:问答    javascript   asp.net   replace   expression

XSL replace space with caret

UPDATED CODE: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="no"/> <!-- overwritten by application with actual values --> <xsl:param name="calling" select="'SAMPLE_MOD'"/> <xsl:param name="called" select="'SERVER1'"/> <xsl:param name="date" select="'20051206'"/> <xsl:param name="time" select="'115600.000'"/> <xsl:param name="PatName" select="attr[@tag='00100010']"/> <xsl:template match="/dataset"> <dataset> <xsl:variable name="PerfProcStepDesc" select="attr[@tag='00400254']"/> <xsl:variable

2022-01-18 05:53:05    分类:问答    xslt   replace   spaces

match and replace multiple newlines with a SED or PERL one-liner

I have an input C file (myfile.c) that looks like this : void func_foo(); void func_bar(); //supercrazytag I want to use a shell command to insert new function prototypes, such that the output becomes: void func_foo(); void func_bar(); void func_new(); //supercrazytag So far I've been unsuccessful using SED or PERL. What didn't work: sed 's|\n\n//supercrazytag|void func_new();\n\n//supercrazytag|g' < myfile.c sed 's|(\n\n//supercrazytag)|void func_new();\1|g' < myfile.c Using the same patterns with perl -pe "....." didn't work either. What am I missing ? I've tried many different approaches

2022-01-18 03:32:54    分类:问答    perl   sed   newline   replace   multiline

Remove Only First Word From Given String

I'm trying to remove first word from given string. I'm done so far... $word = 'removeMe|meow|whatever'; $needle = 'removeMe'; $haystack = ''; // To replace with. $word = str_replace( $needle, $haystack, $word ); It's working great, but problem is when $word is something like this... $word = 'removeMe|meow|removeMe|whatever'; I don't want to remove second $needle. Is it possible and how? )

2022-01-18 03:13:39    分类:问答    php   replace

How to ignore parts of the text and do search-and-replace in the remaining part? [duplicate]

This question already has an answer here: In Perl, how to "jump over" certain text and do search-and-replace in the remaining part? [duplicate] (1 answer) Closed 5 years ago. While doing regex find-and-replace in text file, I wanna jump over & ignore certain segments of the text. That is, certain parts of the text should be excluded from the search, and only do search & replace in the remaining parts. The criteria is: (1) anything between START and END should be excluded from the search & replace. START may or may not be at the start of a line; END may or may not be at the end of a line; one

2022-01-18 01:25:59    分类:问答    regex   perl   replace   conditional