italicized Words inside fpdf cell - cell

is there any way i can italicized a certain words inside $this->Cell(0,3,'Hello, my name is (italicized) John Doe.',0,1,'C');
I just need to emphasized the name 'John Doe' and not the whole sentence.
Please help. Thanks.

Unfortunately you can't do that directly with only FPDF functions. What you need here is to code a new function wich recreate Cell() with some new parameters...
But wait... someone already did that!
It's here: FPDF Add-On by Pascal Morin
It's such a great job that you don't even need something else! :)

Related

Regex: How to extract dialogue tags from fiction, with speaker information

Totally stumped on this. I need help extracting dialogue from a story so I can hand it off for narration.
Basically, this is a problem where I have a big chunk of text (a novel), and I want to extract all the dialogue from the text in a format I can pipe into a spreadsheet.
But, I also want, if it exists, the speaker information as well. So, given a string like:
'"I'm really hungry," she said.'
I would like the values returned as:
[ "I'm really hungry", "she said" ]
If there is no dialogue, as in this example:
"I'm not hungry."
the result would just be:
["I'm really hungry."]
Is this madness? Is it even possible? I have fooled around with this regex (am not a regex guru, knowing only enough to be dangerous):
"([^"]*)"
Which seems to get the dialogue tags, but doesn't get the speaker info. Any advice in how to get the speaker info as well would be greatly appreciated. I've been wrestling with this for awhile now.
Maybe a better approach would be to get the dialogue in one field, and the entire paragraph it is found in as the second field. That could also work, but I have no idea where to start with this.
Basically I want to put these all into a spreadsheet so I can hand them off to a narrator with enough context that they know whose dialogue is who's in the story.
Any help is greatly appreciated!
It definitely is possible
Look at this regex: ^.*?'?(?P<line>\".*\")(?P<actor>[^'\n]*)'?.*?$
demo here: https://regex101.com/r/UCRZwY/5
It basically marks the outer quotes as optional, but if it does find them, stores whatever provided as '$actor' (and the line as '$line') these are of course just names i've given them, feel free to change
Note updated to include such text as part of regular sentence, see example in demo

How to coded reference from an APA a reference in excel?

I have a database with APA references in a column like this one (let's sake it's in A6 for the sake of our example) in Google Sheets (online reproducibility aimed)
Smith (2010) Assessing the Impact of Aimhigher Kent and Medway
I would like to create a new code column with just the last name of the first author and the date. For our example, that would be
Smith2010
I tried things like
=REGEXEXTRACT(A6; "\w.(\d\d\d\d)")
but it doesn't work. Could you help me please in this very low-level issue?
Thanks in advance,
One option is to use REGEXREPLACE with 2 capturing groups, and use those groups in the replacement.
^[^\S\r\n]*(\w+)[^()\r\n]+\((\d{4})\).*
Regex demo
=REGEXREPLACE(A6; "^[^\S\r\n]*(\w+)[^()\r\n]+\((\d{4})\).*"; "$1$2")
Thanks to #The fourth bird the solution is:
> =REGEXREPLACE(A6; "^[^\S\r\n]*?(\w+)[^()\r\n]+\((\d{4})\).*"; "$1$2")
Thanks a lot for the ones who helped !!

String replacement in Perl after comparing with the original string

I want to compare a string in perl below is detail description
original string
../db/proj/upload/1/22352/eng_wall_paper.jpg
I need to extract the file name eng_wall_paper.jpg from the string
and compare it with variable and append the new variable to the string.
new required string
../db/proj/upload/1/22352/new string.jpg
how can it be done, thanks in advance .
Now as you can see in the comment in your question that you really need to be specific about where you are actually stuck in to ask a question in SO. However, after looking at your other questions in SO it looks like you are completely new in programming world and need serious helping hand. Hence I think it would be helpful for you to get some useful reference to solve your problem.
If I breakdown your main problem statement I can see three parts
1. Need to extract the file name,
Most recommended way to do it is using File::Basename. However, its possible to use regex too. You need to learn how to write regex and how to capture a group. This link should be really helpful.
2. Compare it with variable,
Whichever method you use from above you should get the filename in a variable or in $1. Just compare that whatever you want to compare with. Make sure to use eq instead of ==. Find more details here.
3. Append the new variable to the string,
By now you should have the old filename in a variable, say $oldname, from first step and the new filename in another variable, say $newfilename. This question is already answered several times in SO, like this one. Hope that helps.
The actual solution is merely a 3 or 4 lines of code which I want you to figure out. Good luck.

How to create a regex to check whether a set of words exists in a given string?

How can I write a regex to check if a set of words exist in a given string?
For example, I would like to check if a domain name contains "yahoo.com" at the end of it.
'answers.yahoo.com', would be valid.
'yahoo.com.answers', would be wrong. 'yahoo.com' must come in the end.
I got a hint from somewhere that it might be something like this.
"/^[^yahoo.com]$/"
But I am totally new to regex. So please help with this one, then I can learn further.
When asking regex questions, always specify the language or application, too!
From your history it looks like JavaScript / jQuery is most likely.
Anyway, to test that a string ends in "yahoo.com" use /.*yahoo\.com$/i
In JS code:
if (/.*yahoo\.com$/i.test (YOUR_STR) ) {
//-- It's good.
}
To test whether a set of words has at least one match, use:
/word_one|word_two|word_three/
To limit matches to just the most-common, legal sub-domains, ending with "yahoo.com", use:
/^(\w+\.)+yahoo\.com$/
(As a crude, first pass)
For other permutations, please clarify the question.

Extract pattern substring from NSString

I've created my own UITabBarController.
Additionally I've written a few lines of code to determine the current user.
E.g. if I am the current user do/display this, otherwise do/display this etc...
The format pattern is (firstname Lastname).
The Full name of the current user is in "displayName".
This is how I set the title of the tab depending on whether I am looking at 'my' tabs or someone else's tabs.
[activities setTitle:[viewingUser objectForKey:#"displayName"]];
I now want to extract only the firstname and display it like so:
"firstname's".
I do know of substringToIndex and substringWithRange but I just can't seem to work it out myself. I reckon I just need to find the first and extract the part it togehter with that ['s]. Can anybody please point me in the right direction?
Cheers
If first name and last name are separated by a space then simply execute the following statement which returns an NSArray which in your will contain the first and last names.
[displayName componentsSeparatedByString:#" "]
Take a look at the NSScanner documentation and associated sample code. There are simpler ways to do it if that is your only dataset, however, the moment you start getting into even semi-complex sequences, you'll need other, more powerful solutions. This is why I'm recommending NSScanner off the top.