I have these variables:
$cities = [
'New York City',
'Arizona State',
'Arkansas State'
];
$teams = [
'New York Mets',
'New York Yankees',
'Arizona State Sun Devils',
'Arkansas State Red Wolves'
];
How can I format the $teams array into the following:
$teams = [
'Mets',
'Yankees',
'Sun Devils',
'Red Wolves'
];
Thanks!
there are a dozen options, here is one, wont work if you have a any word in the city list that matches any word in the team list you want to keep. But will work for the data provided.
<?php
$cities = [
'New York City',
'Arizona State',
'Arkansas State'
];
$teams = [
'New York Mets',
'New York Yankees',
'Arizona State Sun Devils',
'Arkansas State Red Wolves'
];
$r=implode($cities,'|');//join the cities
$r=str_replace(' ','|',$r);//separate each word with | for the regular expression
$out=preg_replace('#'.$r.'#','',$teams); // regular expression replace
use the function str_replace. example:
<?php
$teams = [
'New York Mets',
'New York Yankees'
];
$out = str_replace('New York', '', $teams);
print_r($out); // Output: Array ( [0] => Mets [1] => Yankees )
?>
str_replace() can do the work for you, as it accepts arrays as parameters too. However, you'll run into an issue with New York City. If you're not able to either rename it to New York, or add New York as a separate element, you need to remove that first (with the str_replace()-line after the $city declaration), before you supply the $city to the str_replace() where you replace out the cities with empty strings.
$cities = [
'New York City',
'Arizona State',
'Arkansas State'
];
$cities = str_replace("City", "", $cities);
$teams = [
'New York Mets',
'New York Yankees',
'Arizona State Sun Devils',
'Arkansas State Red Wolves'
];
// Replace cities in $cities to an empty string in the $teams array
$teams = str_replace($cities, "", $teams);
$teams = array_map("trim", $teams); // Trim away the excessive spaces
print_r($teams);
Output:
Array (
[0] => Mets
[1] => Yankees
[2] => Sun Devils
[3] => Red Wolves
)
Live demo
PHP.net on str_replace()
Related
I have to replace strings of multiple country names to their translations in another language. So I created an array of countries, where the keys are the countries in English and the values are the countries in the destination language...
So, let me first put a relevant extract of the array I used:
$countries = array(
//...
'Canada' => 'Καναδάς',
//...
'France' => 'Γαλλία',
//...
'Germany' => 'Γερμανία',
//...
'Korea' => 'Κορέα',
//...
'South Korea' => 'Νότια Κορέα',
//...
'United States' => 'Ηνωμένες Πολιτείες',
//...
'West Germany' => 'Δυτική Γερμανία',
//...
);
And the code I used is this:
$tmp[] = str_replace(array_keys($countries), $countries, $api->getCountry());
And below are two (special case) examples that are giving me a hard time figuring out how to deal with them...
West Germany • France
United States • Canada • South Korea
So the above two examples are replaced like this:
West Γερμανία • Γαλλία
Ηνωμένες Πολιτείες • Καναδάς • South Κορέα
I think it's very obvious what's happening here... The key Germany is found before the key West Germany, so str_replace replaces the Germany part with the translated name of it, and so West remains untranslated... The same happens with Korea, which (alphabetically) happens to be before South Korea...
Moving West Germany and South Korea above Germany and Korea fixes the problem, but this is not the proper way to deal with this I suppose, as it will happen to East Germany, and generally, any other country that has a two-word, etc...
What's the correct way to deal with this in your opinion? TIA
This is a little bit of a cheat but if you're going to use array_keys rather than a loop, you should just presort the countries array by length.
$keys = array_map('strlen', array_keys($countries));
array_multisort($keys, SORT_DESC, $countries);
$tmp[] = str_replace(array_keys($countries), $countries, $api->getCountry());
Here's a little example you can test at: https://www.tehplayground.com/uARSRel47jYICSIA
$countries = array(
'Canada' => 'Καναδάς',
'France' => 'Γαλλία',
'Germany' => 'Γερμανία',
'Korea' => 'Κορέα',
'South Korea' => 'Νότια Κορέα',
'United States' => 'Ηνωμένες Πολιτείες',
'West Germany' => 'Δυτική Γερμανία'
);
$keys = array_map('strlen', array_keys($countries));
array_multisort($keys, SORT_DESC, $countries);
echo str_replace(array_keys($countries), $countries, "West Germany"). "\n";
echo str_replace(array_keys($countries), $countries, "France") . "\n";
echo str_replace(array_keys($countries), $countries, "United States") . "\n";
echo str_replace(array_keys($countries), $countries, "Canada") . "\n";
echo str_replace(array_keys($countries), $countries, "South Korea") . "\n";
Output:
Δυτική Γερμανία
Γαλλία
Ηνωμένες Πολιτείες
Καναδάς
Νότια Κορέα
Update
As it turns out uksort takes care of this in one line:
uksort($countries,function($a, $b) { return strlen($b) > strlen($a);});
I have a php array below and i want to know how to get number of companies who did a training course. Look below:
Array
(
[0] => Array
(
[date_creation] => Apr 10, 2021 10:17 pm
[idformation] => 84
[idsociete] => 7
[training] => ELECTRICAL SAFETY TRAINING
[company] => ALUCAM
)
[1] => Array
(
[date_creation] => Apr 10, 2021 10:55 pm
[idformation] => 84
[idsociete] => 7
[training] => ELECTRICAL SAFETY TRAINING
[company] => ALUCAM
)
[2] => Array
(
[date_creation] => Apr 12, 2021 03:27 pm
[idformation] => 104
[idsociete] => 201
[training] => FORKLIFT, JLG SCISSOR LIFT, AERAL PLATFORM
[company] => US EMBASSY
)
);
Each array represents the record of a worker in the database from a company say Alucam and did training Electrical safety.
So from the array above i want to get something like:
2 Alucams did electrical safety as seen in the array.
I just need a clue on how to get the count of persons who did a particular training from the array.
Please help
I assume you can have the same training from different companies, opposite case you can simplified the code.
Input data (I simplified your input array, including only the fields I need):
$workers = array(array("training" => "ELECTRICAL SAFETY TRAINING", "company" => "ALUCAM"),
array("training" => "ELECTRICAL SAFETY TRAINING", "company" => "ALUCAM"),
array("training" => "FORKLIFT, JLG SCISSOR LIFT, AERAL PLATFORM", "company" => "US EMBASSY"),
array("training" => "FORKLIFT, JLG SCISSOR LIFT, AERAL PLATFORM", "company" => "ALUCAM")
);
Php code:
$trainingCount = array();
foreach($workers as $worker) {
$training = $worker["training"];
$company = $worker["company"];
if(! array_key_exists($training, $trainingCount)) {
$trainingCount[$training] = array();
}
if(! array_key_exists($company, $trainingCount[$training])) {
$trainingCount[$training][$company] = 0;
}
$trainingCount[$training][$company]++;
}
Result:
array('ELECTRICAL SAFETY TRAINING' => array('ALUCAM' => 2), 'FORKLIFT, JLG SCISSOR LIFT, AERAL PLATFORM' => array('US EMBASSY' => 1, 'ALUCAM' => 1));
Effectively you have a list of employees with their training listed in a comma separated list?
So basically you need to iterate through the list stripping out the information you require (company & training). Then every time you get a match you increment the matching data.
There are a few ways to do this the simplest would be to iterate through the results to create an array which looks something like...
$countArray = [
"Alucam" => [
"ELECTRICAL SAFETY TRAINING" = 2,
],
];
The code would look like:
$countArray = [];
// Generate the array
foreach ($array as $employee) {
$trainingList = array_map("trim", explode(",", $employee["training"]));
foreach ($trainingList as $training) {
$countArray[$employee["company"]][$training] = ($countArray[$employee["company"]][$training] ?? 0) + 1;
}
}
// Generate the output
foreach ($countArray as $companyName => $training) {
foreach ($training as $trainingName => $trainingCount) {
echo "{$trainingCount} {$companyName} did {$trainingName}", PHP_EOL;
}
}
/*
Output:
2 ALUCAM did ELECTRICAL SAFETY TRAINING
1 US EMBASSY did FORKLIFT
1 US EMBASSY did JLG SCISSOR LIFT
1 US EMBASSY did AERAL PLATFORM
*/
However, this does mean you can have "unusual" characters in array keys which could lead to problems further down the line. So you may do better with a slightly more complicated approach (i.e. having index arrays for the company and training names) which gives an array a little something like...
$countArray = [
'company' => [
0 => 'ALUCAM',
1 => 'US EMBASSY',
],
'training' => [
0 => 'ELECTRICAL SAFETY TRAINING',
1 => 'FORKLIFT',
2 => 'JLG SCISSOR LIFT',
3 => 'AERAL PLATFORM',
],
'count' => [
0 => [
0 => 2,
],
1 => [
1 => 1,
2 => 1,
3 => 1,
],
],
];
The code would look like:
// Generate the array
foreach ($array as $employee) {
if (false === ($companyIndex = array_search($employee["company"], $countArray["company"]))) {
$companyIndex = count($countArray["company"]);
$countArray["company"][] = $employee["company"];
}
$trainingList = array_map("trim", explode(",", $employee["training"]));
foreach ($trainingList as $training) {
if (false === ($trainingIndex = array_search($training, $countArray["training"]))) {
$trainingIndex = count($countArray["training"]);
$countArray["training"][] = $training;
}
$countArray["count"][$companyIndex][$trainingIndex] = ($countArray["count"][$companyIndex][$trainingIndex] ?? 0) + 1;
}
}
// Generate the output
foreach ($countArray["count"] as $companyKey => $companyCount) {
$companyName = $countArray["company"][$companyKey];
foreach ($companyCount as $trainingKey => $trainingCount) {
$trainingName = $countArray["training"][$trainingKey];
echo "{$trainingCount} {$companyName} did {$trainingName}", PHP_EOL;
}
}
You can use array_count_values and array_column to achieve something like this: You can modify as required.
$arr = [
['date_creation' => 'Apr 10, 2021 10:17 pm', 'idformation' => 84, 'idsociete' => 7, 'training' => 'ELECTRICAL SAFETY TRAINING', 'company' => 'ALUCAM'],
['date_creation' => 'Apr 10, 2021 10:17 pm', 'idformation' => 84, 'idsociete' => 7, 'training' => 'ELECTRICAL SAFETY TRAINING', 'company' => 'ALUCAM'],
['date_creation' => 'Apr 12, 2021 03:27 pm', 'idformation' => 104, 'idsociete' => 201, 'training' => 'FORKLIFT, JLG SCISSOR LIFT, AERAL PLATFORM', 'company' => 'US EMBASSY'],
];
$training = 'ALUCAM';
$companies = array_count_values(array_column($arr, 'company'))[$training]; // outputs: 2
I need to parse a street address in PHP a string that might have abbreviations.
This string comes from a text input.
The fields I need to search are:
street (alphanumeric - might have
building (alphanumeric - might have
number (alphanumeric - might have
area (numeric from 1 to 5)
other (unknown field & used to search in all the above fields in the database)
For example users submits one of this text text:
street Main Road Bulding H7 Number 5 Area 1
st Main Road bldg H7 Nr 5 Ar 5
stMain bldgh7
ar5 unknown other search parameter
street Main Road h7 2b
street main street str main road
The outcome I would like to see as a array:
[street]=>Main Road [building]=>h7 [number]=>5 [area]=>1
[street]=>Main Road [building]=>h7 [number]=>5 [area]=>5
[street]=>Main [building]=>h7
[area]=>5 [other]=>unknown other search parameter
[street]=>Main Road [other]=>h7 2b
[street]=>Main Street&&Main Road
My code so far...but dosen't work with examples 3.,4.,5.,6.:
<?php
//posted address
$address = "str main one bldg 5b other param area 1";
//to replace
$replace = ['street'=>['st','str'],
'building'=>['bldg','bld'],
'number'=>['nr','numb','nmbr']];
//replace
foreach($replace as $field=>$abbrs)
foreach($abbrs as $abbr)
$address = str_replace($abbr.' ',$field.' ',$address);
//fields
$fields = array_keys($replace);
//match
if(preg_match_all('/('.implode('|',array_keys($fields)).')\s+([^\s]+)/si', $address, $matches)) {
//matches
$search = array_combine($matches[1], $matches[2]);
//other
$search['other'] = str_replace($matches[0],"",$address);
}else{
//search in all the fields
$search['other'] = $address;
}
//search
print_r($search);
Code tester: http://ideone.com/j3q4YI
Wow, you've got one hairy mess to clean up. I've toiled for a few hours on this. It works on all of your samples, but I would NOT stake my career on it being perfect on all future cases. There are simply too many variations in addresses. I hope you can understand my process and modify it if/when new samples failed to be captured properly. I'll leave all my debugging comment in place, because I reckon you'll use them for future edits.
$addresses=array(
"street Main Road Bulding H7 Number 5 Area 1",
"st Main Road bldg H7 Nr 5 Ar 5",
"stMain bldgh7",
"ar5 unknown other search parameter",
"street Main Road h7 2b",
"street main street str main road"
);
$regex["area"]="/^(.*?)(ar(?:ea)?\s?)([1-5])(.*?)$/i";
$regex["number"]="/^(.*?)(n(?:umbe)?r\s?)([0-9]+)(.*?)$/i";
$regex["building"]="/^(.*?)(bu?i?ldi?n?g\s?)([^\s]+)(.*?)$/i";
$regex["corner"]="/^(.*?str?(?:eet)?)\s?(str?(?:eet)?.*)$/i"; // 2 streets in string
$regex["street"]="/^(.*?)(str?(?:eet)?\s?)([^\s]*(?:\s?ro?a?d|\s?str?e?e?t?|.*?))(\s?.*?)$/i";
$regex["other"]="/^(.+)$/";
$search=[];
foreach($addresses as $i=>$address){
echo "<br><div><b>$address</b> breakdown:</div>";
foreach($regex as $key=>$rgx){
if(strlen($address)>0){
//echo "<div>addr(",strlen($address),") $address</div>";
if(preg_match($rgx,$address,$matches)){
if($key=="other"){
$search[$i][$key]=$matches[0]; // everything that remains
}elseif($key=="corner"){
$search[$i]["street"]=""; // NOTICE suppression
// loop through both halves of corner address omitting element[0]
foreach(array_diff_key($matches,array('')) as $half){
//echo "half= $half<br>";
if(preg_match($regex["street"],$half,$half_matches)){
//print_r($half_matches);
$search[$i]["street"].=(strlen($search[$i]["street"])>0?"&&":"").ucwords($half_matches[3]);
$address=trim($half_matches[1].$half_matches[4]);
// $matches[2] is the discarded identifier
//echo "<div>$key Found: {$search[$i][$key]}</div>";
//echo "<div>Remaining: $address</div>";
}
}
}else{
$search[$i][$key]=($key=="street"?ucwords($matches[3]):$matches[3]);
$address=trim($matches[1].$matches[4]);
// $matches[2] is the discarded identifier
//echo "<div>$key Found: {$search[$i][$key]}</div>";
//echo "<div>Remaining: $address</div>";
//print_r($matches);
}
}
}else{
break; // address is fully processed
}
}
echo "<pre>";
var_export($search[$i]);
echo "</pre>";
}
The output is an array that satisfies your brief, but the keys are out of order because I captured the address components out of order -- this may not matter to you, so I didn't bother re-sorting it.
street Main Road Bulding H7 Number 5 Area 1 breakdown:
array (
'area' => '1',
'number' => '5',
'building' => 'H7',
'street' => 'Main Road',
)
st Main Road bldg H7 Nr 5 Ar 5 breakdown:
array (
'area' => '5',
'number' => '5',
'building' => 'H7',
'street' => 'Main Road',
)
stMain bldgh7 breakdown:
array (
'building' => 'h7',
'street' => 'Main',
)
ar5 unknown other search parameter breakdown:
array (
'area' => '5',
'other' => 'unknown other search parameter',
)
street Main Road h7 2b breakdown:
array (
'street' => 'Main Road',
'other' => 'h7 2b',
)
street main street str main road breakdown:
array (
'street' => 'Main Street&&Main Road',
)
...boy am I glad this project doesn't belong to me. Good luck!
Thank you for the help! I thought that I should do something like multiple preg_matches.
I just found a PHP extension that does exactly what I want.
The library is PHP Postal (https://github.com/openvenues/php-postal) and requires libpostal. It takes about 15-20 seconds to load the library when you run PHP, after this everything work ok.
Total execution time for parsing: 0.00030-0.00060 seconds.
$parsed = Postal\Parser::parse_address("The Book Club 100-106 Leonard St, Shoreditch, London, Greater London, EC2A 4RH, United Kingdom");
foreach ($parsed as $component) {
echo "{$component['label']}: {$component['value']}\n";
}
Output:
house: the book club
house_number: 100-106
road: leonard st
suburb: shoreditch
city: london
state_district: greater london
postcode: ec2a 4rh
country: united kingdom
All I had to do after this is to replace my labels and format the address.
Hope this will help others, who want to parse a address in PHP.
I want to classify cities with the products they have.
I have two documents: Product and city. The product has its ID and a reference to a city document:
Product(id) City
P1 ------------ Atlanta
P2 ------------ New York
P3 ------------ Michigan
P4 ------------ Atlanta
....
I want as result of the query
[Atlant => 23, New York => 35, Michigan => 23, etc..]
But I not being able to get the result.
My actual code is
public function countBestUsers()
{
return $this->createQueryBuilder()
->select('id', 'city')
->distinct('city')
->getQuery()
->execute()
;
}
You can try with group and reduce, this example works for me:
$count = $dm->createQueryBuilder()->hydrate(false)
->group(array('city.$id' => 1), array('value' => 0))
->reduce('function (curr,result) {
result.value++;
}')
->getQuery()
->execute()->toArray();
If you need more examples : http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/query-builder-api.html#group-queries
If you will sort it by the quantities, I recommend use aggregate Framework:
$pipeline = array('$group' => array(
'_id' => '$city',
'value' => array('$sum' => 1)
)));
array_push($pipeline, array( '$sort' => array('value' => -1) ) );
$count = $dm->getDocumentCollection('YourBundle:Product')
->aggregate($pipeline)->toArray();
I have a text file with a Bibtex export.
The text file has a number of entries following the pattern below.
#article{ls_leimeister,
added-at = {2013-01-18T11:14:11.000+0100},
author = {Wegener, R. and Leimeister, J. M.},
biburl = {http://www.bibsonomy.org/bibtex/27bb26b4b4858439f81aa0ec777944ac5/ls_leimeister},
journal = {International Journal of Technology Enhanced Learning (to appear)},
keywords = {Challenges Communities: Factors Learning Success VirtualCommunity and itegpub pub_jml pub_rwe},
note = {JML_390},
title = {Virtual Learning Communities: Success Factors and Challenges},
year = 2013
}
I want to use php and considered preg_match_all
The following didnt get me anywhere:
preg_match_all('/#^.*}$/', file_get_contents($file_path),$results);
I wanted to start simple, but that didnt really work.
I am kinda new to php RegEx.
The perfect final output would be:
Array
(
[0] => Array
(
['type'] => article
['unique_name'] => ls_leimeister
['added-at'] => 2013-01-18T11:14:11.000+0100
['author'] => Wegener, R. and Leimeister, J. M.
['biburl'] => http://www.bibsonomy.org/bibtex/27bb26b4b4858439f81aa0ec777944ac5/ls_leimeister
['journal'] => International Journal of Technology Enhanced Learning (to appear)
['keywords'] => Challenges Communities: Factors Learning Success VirtualCommunity and itegpub pub_jml pub_rwe
['note'] => JML_390
['title'] => Virtual Learning Communities: Success Factors and Challenges
['year'] => 2013
)
[1] => Array
(
[...] => …
)
)
Try this : Here I have fetched only type and unique_name, by looking at it, you can fetch all others.
$str = '#article{ls_leimeister,
added-at = {2013-01-18T11:14:11.000+0100},
author = {Wegener, R. and Leimeister, J. M.},
biburl = {http://www.bibsonomy.org/bibtex/27bb26b4b4858439f81aa0ec777944ac5/ls_leimeister},
journal = {International Journal of Technology Enhanced Learning (to appear)},
keywords = {Challenges Communities: Factors Learning Success VirtualCommunity and itegpub pub_jml pub_rwe},
note = {JML_390},
title = {Virtual Learning Communities: Success Factors and Challenges},
year = 2013
}';
preg_match_all('/#(?P<type>\w+){(?P<unique_name>\w+),(.*)/',$str,$matches);
echo $matches['type'][0];
echo "<br>";
echo $matches['unique_name'][0];
echo "<br>";
echo "<pre>";
print_r($matches);
Output array format will be little different from yours, but you can change this format to yours.
Pattern: /^#([^{]+)\{([^,]+),\s*$|^\s*([^\R#=]+) = \{(.*?)}/ms (Demo)
This pattern has two alternatives; each containing two capture groups.
type and unique_name are captured and stored in elements [1] and [2].
all other key-value pairs are stored in elements [3] and [4].
This separated array storage allows reliable processing when constructing the desired output array structure.
Input:
$bibtex='#BOOK{ko,
title = {Wissenschaftlich schreiben leicht gemacht},
publisher = {Haupt},
year = {2011},
author = {Kornmeier, M.},
number = {3154},
series = {UTB},
address = {Bern},
edition = {4},
subtitle = {für Bachelor, Master und Dissertation}
}
#BOOK{nial,
title = {Wissenschaftliche Arbeiten schreiben mit Word 2010},
publisher = {Addison Wesley},
year = {2011},
author = {Nicol, N. and Albrecht, R.},
address = {München},
edition = {7}
}
#ARTICLE{shome,
author = {Scholz, S. and Menzl, S.},
title = {Alle Wege führen nach Rom},
journal = {Medizin Produkte Journal},
year = {2011},
volume = {18},
pages = {243-254},
subtitle = {ein Vergleich der regulatorischen Anforderungen und Medizinprodukte
in Europa und den USA},
issue = {4}
}
#INBOOK{shu,
author = {Schulz, C.},
title = {Corporate Finance für den Mittelstand},
booktitle = {Praxishandbuch Firmenkundengeschäft},
year = {2010},
editor = {Hilse, J. and Netzel, W and Simmert, D.B.},
booksubtitle = {Geschäftsfelder Risikomanagement Marketing},
publisher = {Gabler},
pages = {97-107},
location = {Wiesbaden}
}';
Method: (Demo)
$pattern='/^#([^{]+)\{([^,]+),\s*$|^\s*([^\R#=]+) = \{(.*?)}/ms';
if(preg_match_all($pattern,$bibtex,$out,PREG_SET_ORDER)){
foreach($out as $line){
if(isset($line[1])){
if(!isset($line[3])){ // this is the starting line of a new set
if(isset($temp)){
$result[]=$temp; // send $temp data to permanent storage
}
$temp=['type'=>$line[1],'unique_name'=>$line[2]]; // declare fresh new $temp
}else{
$temp[$line[3]]=$line[4]; // continue to store the $temp data
}
}
}
$result[]=$temp; // store the final $temp data
}
var_export($result);
Output:
array (
0 =>
array (
'type' => 'BOOK',
'unique_name' => 'ko',
'title' => 'Wissenschaftlich schreiben leicht gemacht',
'publisher' => 'Haupt',
'year' => '2011',
'author' => 'Kornmeier, M.',
'number' => '3154',
'series' => 'UTB',
'address' => 'Bern',
'edition' => '4',
'subtitle' => 'für Bachelor, Master und Dissertation',
),
1 =>
array (
'type' => 'BOOK',
'unique_name' => 'nial',
'title' => 'Wissenschaftliche Arbeiten schreiben mit Word 2010',
'publisher' => 'Addison Wesley',
'year' => '2011',
'author' => 'Nicol, N. and Albrecht, R.',
'address' => 'München',
'edition' => '7',
),
2 =>
array (
'type' => 'ARTICLE',
'unique_name' => 'shome',
'author' => 'Scholz, S. and Menzl, S.',
'title' => 'Alle Wege führen nach Rom',
'journal' => 'Medizin Produkte Journal',
'year' => '2011',
'volume' => '18',
'pages' => '243-254',
'subtitle' => 'ein Vergleich der regulatorischen Anforderungen und Medizinprodukte
in Europa und den USA',
'issue' => '4',
),
3 =>
array (
'type' => 'INBOOK',
'unique_name' => 'shu',
'author' => 'Schulz, C.',
'title' => 'Corporate Finance für den Mittelstand',
'booktitle' => 'Praxishandbuch Firmenkundengeschäft',
'year' => '2010',
'editor' => 'Hilse, J. and Netzel, W and Simmert, D.B.',
'booksubtitle' => 'Geschäftsfelder Risikomanagement Marketing',
'publisher' => 'Gabler',
'pages' => '97-107',
'location' => 'Wiesbaden',
),
)
Here is the site that I extracted new sample input strings from.