I have a jHtmlArea as a text input for a web displayed output unfortunately any images or links that are put into the text area are corrupted with a \ before the quotation mark, when echo'd on the output page.
Is there ant way to code this differently?
Input
$text = preg_replace("/\r\n/", '', $_POST[$textIndex]) . PHP_EOL;
echo is
<?php if ($text) : // text ?>
<div><?php echo $text; ?></div>
Found the answer. It's really simple. Just change output to echo stripslashes($text)
Related
OK, I know that what I see is not necessarily what the code says. I got that part figured out. But I have a long list of characters that need to be stored in a database as their html entities rather than as the punctuation marks. I have updated my code to this:
$searchval = array("á","–","—","/"," ","-","...","…","\&","\'","í","\[","\~","\"","\]");
$replaceval = array("\è\;","\&ndash\;","\&mdash\;","\/","\&#nbsp\;","\&#hyphen\;","\&hellip\;","\&hellip\;","\&\;","\&apos\;","\ì\;","\&lbrack\;","\ñ\;","\"\;","\&rbrack\;");
str_replace($searchval,$replaceval,$fixed);
But the entitiy names are not going into the database.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'most # rig&ht...'
How do I get the entities to go into the database rather than the punctuation marks?
<!DOCTYPE html>
<html>
<body style="margin-left:50px">
<?php
$fixed = "this is al'most right";
echo $fixed;
echo "<br>";
echo "htmlspecialchars: ";
echo htmlspecialchars($fixed, ENT_QUOTES);
echo "<br>";
echo "str_replace: ";
echo str_replace("'", "'", $fixed);
echo "<br>";
?>
</body>
</html>
I want to require alternative syntax in controle structure within html files , otherwise, throw error or warning if alternative syntax rules not been respected in whatever instruction .
Below is an example of alternative syntax that should be established:
<?php if (true === $var) : ?>
<h3>Hello world</h3>
<?php else : ?>
<h3>Hello</h3>
<?php endif; ?>
Is there a phpcs sniff which deals with such requirements ? if not , how can we make a customized sniff to check for alternative syntax in html files ?
I want to read a file a extract information from it based on certain tag. For example :
SCRIPT_NAME:mySimpleShell.sh
This is a simple shell. I would like to have this as
Description. I also want to create a txt file our of this.
SCRIPT_NAME:myComplexShell.sh
This is a complex shell. I would like to have this as
Description. I also want to create a txt file our of this.
So when I pass in this file to my shell script, my shell will read it line by line and
when it gets to SCRIPT_NAME, It extract it and save it in $FILE_NAME, then starts writing
the description to a file on disk with $FILE_NAME.txt name. And It does it until It reaches the end of file. If there is 3 SCRIPT_NAME tag, then it creates 3 description file.
Thanks for helping me in advance :)
Read the lines using a while loop. Use a regex to check if a line has SCRIPT_NAME and if so, extract the filename. This is shown below:
#! /bin/bash
while IFS= read -r line
do
if [[ $line =~ SCRIPT_NAME:(.*$) ]]
then
FILENAME="${BASH_REMATCH[1]}"
echo "Writing to $FILENAME.txt"
else
echo "$line" >> "$FILENAME.txt"
fi
done < inputFile
#!/bin/sh
awk '/^SCRIPT_NAME:/ { split( $0, a, ":" ); name=a[2]; next }
name { print > name ".txt" }' ${1?No input file specified}
I am using Run Script in Xcode, I am facing some problem
I am declaring variable like below
URL1 = "/Users/UserName/Desktop/Folder/13072012/libRestKit.a"
And below i am printing it echo "Test $URL1 Test" I tried like this also "Test ${URL1} Test"
I am not able to print the URL1 value, below i use this
echo "Hello, world!"
and i am able to print this, I am new to scripting What is the problem can any one help me out
Try without spaces:
URL1="/Users/UserName/Desktop/Folder/13072012/libRestKit.a"
Putting spaces around = is a common error when using bash and other shells of the same family.
I'd like to grep the following in BBedit.
Find:
<dc:subject>Knowledge, Mashups, Politics, Reviews, Ratings, Ranking, Statistics</dc:subject>
Replace with:
<dc:subject>Knowledge</dc:subject>
<dc:subject>Mashups</dc:subject>
<dc:subject>Politics</dc:subject>
<dc:subject>Reviews</dc:subject>
<dc:subject>Ratings</dc:subject>
<dc:subject>Ranking</dc:subject>
<dc:subject>Statistics</dc:subject>
OR
Find:
<dc:subject>Social web, Email, Twitter</dc:subject>
Replace with:
<dc:subject>Social web</dc:subject>
<dc:subject>Email</dc:subject>
<dc:subject>Twitter</dc:subject>
Basically, when there's more than one category, I need to find the comma and space, add a linebreak and wrap the open/close around the category.
Any thoughts?
Wow. Lots of complex answers here. How about find:
,
(there's a space after the comma)
and replace with:
</dc:subject>\r<dc:subject>
Find:
(.+?),\s?
Replace:
\1\r
I'm not sure what you meant by “wrap the open/close around the category” but if you mean that you want to wrap it in some sort of tag or link just add it to the replace.
Replace:
\1\r
Would give you
Social web
Email
Twitter
Or get fancier with Replace:
\1\r
Would give you
Social web
Email
Twitter
In that last example you may have a problem with the “Social web” URL having a space in it. I wouldn't recommend that, but I wanted to show you that you could use the \1 backreference more than once.
The Grep reference in the BBEdit Manual is fantastic. Go to Help->User Manual and then Chapter 8. Learning how to use RegEx well will change your life.
UPDATE
Weird, when I first looked at this it didn't show me your full example. Based upon what I see now you should
Find:
(.+?),\s?
Replace:
<dc:subject>\1</dc:subject>\r
I don't use BBEdit, but in Vim you can do this:
%s/(_[^<]+)</dc:subject>/\=substitute(submatch(0), ",[ \t]*", "</dc:subject>\r", "g")/g
It will handle multiple lines and tags that span content with line breaks. It handles lines with multiple too, but won't always get the newline between the close and start tag.
If you post this to the google group vim_use and ask for a Vim solution and the corresponding perl version of it, you would probably get a bunch of suggestions and something that works in BBEdit and then also outside any editor in perl.
Don
You can use sed to do this either, in theory you just need to replace ", " with the closing and opening <dc:subject> and a newline character in between, and output to a new file. But sed doesn't seem to like the html angle brackets...I tried escaping them but still get error messages any time they're included. This is all I had time for so far, so if I get a chance to come back to it I will. Maybe someone else can solve the angle bracket issue:
sed s/, /</dc:subject>\n<dc:subject>/g file.txt > G:\newfile.txt
Ok I think I figured it out. Basically had to put the replacement text containing angle brackets in double quotes and change the separator character sed uses to something other than forward slash, as this is in the replacement text and sed didn't like it. I don't know much about grep but read that grep just matches things whereas sed will replace, so is better for this type of thing:
sed s%", "%"</dc:subject>\n<dc:subject>"%g file.txt > newfile.txt
You can't do this via normal grep. But you can add a "Unix Filter" to BBEdit doing this work for you:
#!/usr/bin/perl -w
while(<>) {
my $line = $_;
$line =~ /<dc:subject>(.+)<\/dc:subject>/;
my $content = $1;
my #arr;
if ($content =~ /,/) {
#arr = split(/,/,$content);
}
my $newline = '';
foreach my $part (#arr) {
$newline .= "\n" if ($newline ne '');
$part =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;
$newline .= "<dc:subject>$part</dc:subject>";
}
print $newline;
}
How to add this UNIX-Filter to BBEdit you can read at the "Installation"-Part of this URL: http://blog.elitecoderz.net/windows-zeichen-fur-mac-konvertieren-und-umgekehrt-filter-fur-bbeditconverting-windows-characters-to-mac-and-vice-versa-filter-for-bbedit/2009/01/