Skip to content

Instantly share code, notes, and snippets.

@elminson
Last active August 29, 2015 14:22
Show Gist options
  • Save elminson/4152ad45ac8edfbcefc8 to your computer and use it in GitHub Desktop.
Save elminson/4152ad45ac8edfbcefc8 to your computer and use it in GitHub Desktop.
Get Original Files
4
jfjr959493ajsks999s9_A.txt
sieeke4444abcksl4krk_A.cpp
a8b95b8k4ra9f4ka92kf_A.cs
A.java
<?php
$data = file_get_contents('./input.txt', true);
$files = explode("\n", $data);
foreach ($files as $key => $value) {
$file_name=explode(".",$value);
if($file_name[1]!=""){
$file_name2=explode("_",$value);
if($file_name2[1]==""){
echo $file_name2[0]."<br>\n";
} else {
echo $file_name2[1]."<br>\n";
}
}
}
?>
<?php
$data = file_get_contents('./input.txt', true);
$files = explode("\n", $data);
foreach ($files as $key => $value) {
if (preg_match('/[A-Z](.*)/', $value, $match_patern))
{
echo $match_patern[0]."\n";
}
}
?>
A.txt<br>
A.cpp<br>
A.cs<br>
A.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment