Probably a very simple problem and I have been looking for the answer but can not find the it, probably because i have not found out what to ask.
I want the following output, see the '%' character in the output:
(33%)
i just do not understand how to format in the "%" character so it is seen in the output.
txt2 = [txt2 stringByAppendingFormat:#"(%i)", percentage];
I know that the above stringByAppendingFormat is wrong. I would very much appreciate any help.
Escape it with another % so you get something like this:
txt2 = [txt2 stringByAppendingFormat:#"(%i%%)", percentage];
For a list of all format specifiers to use with the formatting functions, see here.
Related
Why I cannot use str_replace() to replace content between the ""? While I replace links within a file they get skipped since they are within quotes.
Example.
href="/path/to/file/is/here"
should be
href="/New/Path/To/File/Goes/Here"
If the paths/urls were not in quotes, str_replace() would work.
I'm assuming this is PHP. So, from the examples here:
http://php.net/manual/en/function.str-replace.php
You can see that you should not intercalate the same type of quotes.
So try changing the quotes in your code to single quotes or, change, the double quotes in your html to single quotes.
If that's not it, I hope at least that doc reference helps you.
This might help I usually code in java but php is pretty similar. Next time input part of your code so that the community can see your logic.
In your if statement on line 67 the 3rd variable $stringToSearch should be regex not the string your assigning it to. The purpose of regex as you know is to replace characters you don't want in your code as you already know
What you had that was not working:
// replacing string from files
//$stringToSearch = str_replace('"', "!!", $stringToSearch);
$stringToSearch = str_replace($toBeReplaced, $toBeReplacedWith, $stringToSearch);
//$stringToSearch = str_replace("!!", '"', $stringToSearch);
What I am thinking it should be:
$stringToRegex = str_replace('"', "!!", $stringToSearch);
$stringToSearch = str_replace($toBeReplaced, $toBeReplacedWith, $stringToRegex );
If anyone else has any suggestion it would be appreciated as i don't code in php.
I asked a similar question awhile back which got a response, and I applied their logic but it still doesn't work.
Here is what I'm doing
I am setting the LocalVar fine, this works.
But I want to add it to the end of the filename, but it comes out literally exactly the way it looks in the Filename.
This is my output:
Anyone know what's going on? Am I missing something?
You are missing some double quotes. You have ...
="\\fhnsrv02\CCAIFTP\CCAICMSO\Dropoff\CMSO_PROV_Extract--SPD & [LocalVars]![FileDate] & .xlsx"
... which is one long literal string. Try this instead:
="\\fhnsrv02\CCAIFTP\CCAICMSO\Dropoff\CMSO_PROV_Extract--SPD" & [LocalVars]![FileDate] & ".xlsx"
I have an array that have some symbols that I want to remove and even thought I find a solution, I will like to know if this is the right way because I'm afraid if I use it with array will remove the character that I might need on future arrays.
Here is an example item on my array:
$string1='22 | logging monitor informational';
so I try the following:
$string1=~ s/\s{6}\|(?=\s{6})//;
So my output is:
22 logging monitor informational
Is the other way that best match "|". I just want to remove the pipe character.
Thanks in advance
"I want to remove just the pipe character."
OK, then do this:
$string1 =~ s/\|//;
This will remove the first pipe character in the string. (You said in another comment that you don't want to remove any additional pipe characters.) If that's not what you want, then I'd suggest telling us exactly what you do want. We can't read minds, you know.
In the mean time, I'd also strongly recommend reading the Perl regular expressions tutorial.
I want to define a variable /Test123 in perl .I am trying something like this but i am getting error
my $uriReference="Test123";
##Here is where i am trying to create /Test123
my $routingUrl = "\"/".$uriReference."\"";
I think i am doing some mistake here Need help?
You can use qq() instead to emulate double quote interpolation:
my $url = qq("/$uriReference");
Although I do not see anything technically wrong with your assignment, it should assign "/Test123" to your variable. So perhaps the error is about something else. We would know if you had included your error message in your question. There is no reason you should ever not include error messages in questions.
You should also know that you do not need to break up your quotes, you can do this:
my $url = "\"/$uriReference\"";
In Sas9, how can I replace all the , \ / or spaces, and other special characters of my choosing with underscores? A solution either in a datastep or in macro functions would do the trick, I'm just looking for a method to do it.
Thanks
You can use the Perl regular expression functionality built into SAS.
data tmp;
set tmp;
var1 = prxchange('s/[,\/\\]/_/', -1, var);
run;
or something similar.
The translate function might be what you're looking for
field2 = translate(trim(field_name),'_______',' ,.\/()')
Make sure to have as many underscores as you have special characters. Also, because you're translating spaces, you have to use the trim function or else you'll get a bunch of underscores after the name.