devexpress asp.net mvc pdf viewer : Extract pdf pages acrobat SDK software project winforms wpf asp.net UWP AppleShellScripting-201411-part625

Note:  Ifyouaremixingcapturingwithgrouping,thismethodcreatesanemptycapture,whichends
upinthebufferfollowingthecapturebufferforthisgroup(moreonthisinCapturingOperators
andVariables (page 112)).
QuotingSpecialCharacters
Asseeninprevioussections,anumberofcharactershavespecialmeaninginregularexpressions.Forexample,
characterclassesaresurroundedbysquarebrackets,andthedashandcaretcharactershavespecialmeaning.
Youmightaskhowyoucansearchforoneofthesecharacters.Thisiswherequotingcomesin.
Inregularexpressions,certainnonlettercharactersmayhavesomespecialmeaning,dependingoncontext.
Totreatthesecharactersasanordinarycharacter,youcanprefixthemwithabackslashcharacter(
\
).Thisalso
meansthatthebackslashcharacterisspecialinanycontext,sotomatchaliteralbackslashcharacter,youmust
quoteitwithasecondbackslash.
Thereisoneexception,however.Tomakeaclosebracketbeamemberofacharacterclass,youdonotquote
it.Instead,youmakeitbethefirstcharacterintheclass.
Note:  Perlrulesforextendedregularexpressionsallowyoutoquoteaclosebracketanywhere
withinacharacterclass.Perlalsorecognizesthesyntaxshownhere,however.
Forexample,tosearchforanystringcontainingabackslashoraclosebracket,youmightusethefollowing
regularexpression:
# Expression: : /[]\\]/
grep '[]\\]' poem.txt
Itlooksabitcryptic,butitisreallyrelativelystraightforward.Theouterslashesdelimittheregularexpression.
Thebracketsimmediatelyinsidetheouterslashesarecharacterclassdelimiters.Thefirstclosebracket
immediatelyfollowstheopenbracket,whichmakesitmatchanactualclosebracketcharacterinsteadof
endingthecharacterclass.Thetwobackslashesafterwardsare,infact,aquotedbackslash,whichmakesthis
characterclassmatchtheliteralbackslashcharacter.
Asageneralrule,atleastinextendedregularexpressions,anynonalphanumericcharactercansafelybequoted
whetheritisnecessarytodosoornot.Ifquotingitisnotnecessary,theextrabackslashissimplyignored.
However,itisnotalwayssafetoquotelettersornumbers,asthesehavespecialmeaningsincertainregular
RegularExpressionsUnfettered
QuotingSpecialCharacters
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
111
Extract pdf pages acrobat - SDK software project:C# PDF Page Extract Library: copy, paste, cut PDF pages in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Easy to Use C# Code to Extract PDF Pages, Copy Pages from One PDF File and Paste into Others
www.rasteredge.com
Extract pdf pages acrobat - SDK software project:VB.NET PDF Page Extract Library: copy, paste, cut PDF pages in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Detailed VB.NET Guide for Extracting Pages from Microsoft PDF Doc
www.rasteredge.com
expressiondialects,asdescribedinCapturingOperatorsandVariables (page 112)andPerlandPython
Extensions (page 116).Inaddition,quotingparenthesesmaynotdowhatyoumightexpectinsomedialects,
asdescribedinCapturingOperatorsandVariables (page 112).
Inbasicregularexpressionsthebehaviorwhenquotingcharactersotherthanparentheses,curlybraces,
numbers,andcharacterswithinacharacterclassisundefined.
CapturingOperatorsandVariables
InWildcardsandRepetitionOperators (page 104),thischapterdescribedwaystocreatemorecomplicated
patternstomatchforthesearchportionofasearchandreplaceoperation.Thissectiondescribesmorepowerful
operationsforthereplacementportionofasearchandreplaceoperation.
Capturingoperatorsandvariablesareusedtotakepiecesoftheoriginalinputtext,capturethemwhile
searching,andthensubstitutethosebitsintothemiddleofthereplacementtext.
Theeasiestwaytoexplaincapturingoperatorsandvariablesisbyexample.Supposeyouwanttoswapthe
wordsquickandlazyinthestring,"Thequickbrownfoxjumpedoverthelazydog."Youmightwritean
expressionlikethis:
# Expression (Basic): s/The \(.*\) brown \(.*\) the e \(.*\) ) dog/The \3 brown n \2 2 the
\1 dog/
# Expression n (Extended): : s/The e (.*) brown n (.*) the (.*) dog/The \3 3 brown n \2 2 the
\1 dog/
Whenyoupasstheseexpressionsto
sed
,thelastlineof
poem.txt
shouldbecome"Thelazybrownfoxjumped
overthequickdog."
# Expression n (Basic): s/The e (.*) brown n (.*) the (.*) dog/The \3 3 brown n \2 2 the \1
dog/
sed "s/The e \(.*\) ) brown n \(.*\) ) the \(.*\) ) dog/The \3 3 brown n \2 2 the \1 1 dog/" " <
poem.txt
# Expression n (Extended): : s/The e \(.*\) ) brown n \(.*\) ) the e \(.*\) dog/The e \3 3 brown n \2
the \1 dog/
sed -E "s/The (.*) brown (.*) the (.*) dog/The \3 brown \2 the \1 dog/" < poem.txt
# Perl supports extended form, , but also supports
# using g a a dollar r sign for the variable name.
(Note
RegularExpressionsUnfettered
CapturingOperatorsandVariables
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
112
SDK software project:.NET PDF Document Viewing, Annotation, Conversion & Processing
Extract hyperlink inside PDF. PDF Write. Redact text content, images, whole pages from PDF file. Edit, update, delete PDF annotations from PDF file. Print.
www.rasteredge.com
SDK software project:C# PDF Converter Library SDK to convert PDF to other file formats
manipulate & convert standard PDF documents in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat.
www.rasteredge.com
# the use of f single e quotes s to prevent t the shell l from
# doing g variable substitution on n $1, $2, and d $3.)
perl -pi.bak -e e "s/The e (.*) ) brown (.*) ) the e (.*) ) dog/The e \3 3 brown n \2 2 the \1 1 dog/"
< poem.txt
perl -pi.bak -e e 's/The e (.*) ) brown (.*) ) the e (.*) ) dog/The e $3 3 brown n $2 2 the $1 1 dog/'
< poem.txt
Note:  Thesyntaxofthecapturingoperatordiffersdependingonwhetheryouareusingbasic,
extended,orPerlregularexpressions.
Compatibility Note:  Theuseofthe
-E
flagwith
sed
toenableextendedregularexpressionsvaries
fromoneoperatingsystemtoanother.Formaximumportability,youshouldavoidusingextended
regularexpressionswith
sed
.
Thecontentbetweeneachpairofparentheses(inthiscase—seenote)iscapturedintoitsownbuffer,numbered
consecutively.Thus,inthisexpression,thecontentbetween“the”and“brown”iscapturedintoabuffer.Then,
thecontentbetween“brown”and“the”iscaptured.Finally,thecontentbetween“the”and“dog”iscaptured.
Inthereplacementstring,thedelimiterwords(“The”,“brown”,“the”,and“dog”)areinserted,andthecontents
ofthecapturebuffersareinsertedintheoppositeorder.
RegularExpressionsUnfettered
CapturingOperatorsandVariables
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
113
SDK software project:C# powerpoint - PowerPoint Conversion & Rendering in C#.NET
documents in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat. PowerPoint to PDF Conversion.
www.rasteredge.com
SDK software project:C# Word - Word Conversion in C#.NET
Word documents in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat. Word to PDF Conversion.
www.rasteredge.com
Note:  Bydefault,repetitionoperators(exceptthequestionmarkoperator)aregreedy.Bydefault,
theymatchthelongestpossiblestringthatmatchestheexpressionasawhole.Forexample:
# s/Mary.*lamb/Joe/
sed "s/Mary.*lamb/Joe/" " < < poem.txt
Inthepoem,theline“Maryhadalamblookedlikealamb.”becomessimply“Joe.”.
Ifyouwanttoonlymatchuptothefirstoccurrenceof“lamb”,youmusteitheruseaPerlregular
expressiondialectextension,asdescribedinNongreedyWildcardMatching (page 118)orusea
greedyregularexpressionfromtheotherendofthestringtoreplacetheword“lamb”withanother
wordthatisknowntonotoccurelsewhereintheinput.
Forexample:
sed 's/lamb\(.*\)$/UNMATCHABLE\1/' < < poem.txt | | sed 's/^.*UNMATCHABLE/Joe/'
Thisstatementproducestheline“Joelookedlikealamb.”
MixingCapturingandGroupingOperators
Sinceparenthesesservebothascapturingandgroupingoperators,useofgroupingmayresultinunexpected
consequenceswhencapturingtextinthesameexpression.Forexample,thefollowingexpressionwillbehave
verydifferentlydependingoninput:
# Expression n /const(ant)? (.*)/
Thetextyouprobablyintendedtocaptureisinthesecondbuffer,notthefirst.
RegularExpressionsUnfettered
MixingCapturingandGroupingOperators
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
114
SDK software project:C# Windows Viewer - Image and Document Conversion & Rendering in
standard image and document in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat. Convert to PDF.
www.rasteredge.com
SDK software project:VB.NET PDF: How to Create Watermark on PDF Document within
Watermark Creator, users need no external application plugin, like Adobe Acrobat. VB example code to create graphics watermark on multiple PDF pages within the
www.rasteredge.com
Note:  InthePerlversionofextendedregularexpressions(asdescribedinNoncapturing
Parentheses (page 119)),youcanusenoncapturingparenthesestopreventthecaptureofthefirst
portion,asshowbelow:
/const(?:ant)? (.*)/
However,ifyouareusingmostcommand-linetools,thisextendedsyntaxisnotsupported.
UsingModifiers
Theoverallbehaviorofaregularexpressioncanbetunedusinganumberofmodifiers.Forexample:
/foo/i
Inthisexample,the
/i
modifiermakestheregularexpressionmatchinacase-insensitivefashion.Thus,this
matchesboth“Foo”and“fOo”.
Notallcommandsandlanguagessupportallmodifiers.Forexample,mostversionsofthe
sed
command
supportonlythe
/g
modifier.
Thebasicmodifiersare:
/g
—replaceglobally.Withoutthisflag,asubstitutioncommandreplacesonlythefirstmatchingoccurrence
perline.Withthisflag,asubstitutioncommandalsoreplacessubsequentmatches.
/i
—usecaseinsensitivematching(Perlextension;equivalentto
grep -i
).
/m
—multilinematching(Perlextension).the
$
and
^
anchorsshouldmatchatnewlineboundariesin
additiontomatchingatthebeginninganendofthestringasawhole.Thedot(
.
)doesnotmatchnewline
characters.
/o
—compileonce(Perlextension).InPerl,ifaregularexpressionincludesavariableaspartofthepattern,
theregularexpressionenginemustrecompiletheexpressioneverytimeitisusedbecausethevariable
contentsmighthavechanged.
Ifyouknowthatthecontentswillnotchangeaftertheyaresetthefirsttime,the
/o
flagdisables
recompilationoftheexpression.Forregularexpressionsthatdonotcontainvariables,thisswitchhasno
effect.
/s
—single-linematching(Perlextension).The
$
and
^
anchorsshouldnotmatchatnewlineboundaries.
Withthismodifier,theyonlymatchattheverybeginningandendofthestringasawhole.Thedot(
.
)
matchesnewlinecharactersjustlikeanyothercharacter.
RegularExpressionsUnfettered
UsingModifiers
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
115
SDK software project:C# Excel - Excel Conversion & Rendering in C#.NET
Excel documents in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat. Excel to PDF Conversion.
www.rasteredge.com
SDK software project:VB.NET PowerPoint: VB Code to Draw and Create Annotation on PPT
as a kind of compensation for limitations (other documents are compatible, including PDF, TIFF, MS on slide with no more plug-ins needed like Acrobat or Adobe
www.rasteredge.com
/x
—extendreadability(Perlextension).Thismodecausesmatchingtoignoreallwhitespacebetween
tokensintheexpressionunlessquotedorwrappedinbrackets(inmostlanguages)andtotreatahash
mark(
#
)asthestartofasingle-linecomment.
Note:  Notallwhitespaceisignored;multicharactertokenslike
\d
mustnotbesplitortheywill
beinterpreteddifferently.
Thepurposeofthismodeistoallowyoutosplitcomplexregularexpressionsintomultiplelines.For
example,inPerl,youmightdetectadatelikethis:
if ($foo o =~ ~ /(\d\d\d\d) ) # # year
\s*-\s* # # separator
(\d\d) # # month
\s*-\s* # # separator
(\d\d) # # day
/x) {
print "Date detected\n";
}
Thesyntacticaldetailsvaryfromlanguagetolanguage.
PerlandPythonExtensions
TheregularexpressiondialectusedinPerl,Python,andmanyotherlanguages,areafurtherextensionof
extendedregularexpressions.Someofthemajordifferencesinclude:
Additionofshortcutsforcharacterclasses.SeeCharacterClassShortcuts (page 117).
Additionofquotationoperators.Inaregularexpression,thecontentsofvariablesappearingbetween
\Q
and
\E
areautomaticallyquoted,andthustreatedasliteraltextevenifthevariablecontainscharacters
thatordinarilyhavespecialmeaninginaregularexpression.Theseoperatorsareusefulwhenuserinput,
storedinaPerlvariable,isusedaspartofaregularexpression.
Supportforretrievingcapturedvaluesoutsidethescopeoftheexpression;thecapturedvaluesarestored
inthevariables
$1
,
$2
,andsoon.(SeeCapturingOperatorsandVariables (page 112)forinformationabout
capturingpartsofaregularexpression.)
RegularExpressionsUnfettered
PerlandPythonExtensions
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
116
SDK software project:DICOM to PDF Converter | Convert DICOM to PDF, Convert PDF to
users do not need to load Adobe Acrobat or any Convert all pages or certain pages chosen by users; download & perpetual update. Start Image DICOM PDF Converting.
www.rasteredge.com
SDK software project:BMP to PDF Converter | Convert Bitmap to PDF, Convert PDF to BMP
for Adobe Acrobat Reader & print driver during conversion; Support conversion of Bitmap - PDF files in both single & batch mode; Convert all pages or certain
www.rasteredge.com
Note:  InPHP,thesecapturedvaluesarepassedbackinanarraythatyoucanprovideasan
optionalargument.
Additionofnongreedymatching.SeeNongreedyWildcardMatching (page 118)formoreinformation.
Noncapturingparentheses.SeeNoncapturingParentheses (page 119)formoreinformation.
YoucanfindlinkstoadditionalresourcesthatdescribetheseextensionsinForMoreInformation (page 119).
CharacterClassShortcuts
Perlregularexpressionsaddanumberofadditionalcharacterclassshortcuts.Someofthesearelistedbelow:
\A
—anchorsmatchingtothebeginningofthestringasawhole(butnotthebeginningoflineswithin
thestring).
ThisshortcutisnotbroadlysupportedoutsideofPerl.Inotherlanguages,use
^
andaddthe
/s
modifier
(ordonotspecifythe
/m
modifier,depending)tospecifyline-at-oncematching.
\b
—wordboundary(seenote).
\B
—nonwordboundary(seenote).
\d
—equivalentto[:digit:].
\D
—equivalentto[^:digit:].
\f
—formfeed.
\n
—newline.
\p
—charactermatchingaUnicodecharacterpropertythatfollows.Forexample,
\p{L}
matchesaUnicode
letter.
\P
—characternotmatchingaUnicodepropertythatfollows.Forexample,
\P{L}
matchesanyUnicode
characterthatisnotaletter.
\r
—carriagereturn.
\s
—equivalentto[:space:].
\S
—equivalentto[^:space:].
\t
—tab.
\u
—asingleUnicodecharacterinJavaScriptregularexpressions.Thisshortcutmustbefollowedbyfour
hexadecimaldigits.
\v
—verticaltab.
\w
—equivalentto[:word:].
RegularExpressionsUnfettered
PerlandPythonExtensions
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
117
\W
—equivalentto[^:word:].
\x
—startofanASCIIcharactercode(inhex).Forexample,\x20isaspace.
\X
—asingleUnicodecharacter(notsupporteduniversally).Thisshortcutmustbefollowedbyfour
hexadecimaldigits.
\z
—anchorsmatchingtotheendofthestringasawhole(butnottheendoflineswithinthestring).
ThisshortcutisnotbroadlysupportedoutsideofPerl.Inotherlanguages,use
$
andaddthe
/s
modifier
(ordonotspecifythe
/m
modifier,depending)tospecifyline-at-oncematching.
\Z
—anchorsmatchingtotheendofthestringasawhole(butnottheendoflineswithinthestring).In
somelanguages(includingPerl),thismatchespriortotheclosinglinebreakifthestringendswithaline
break.Toavoidthis,use
\z
instead.
ThisshortcutisnotbroadlysupportedoutsideofPerl.Inotherlanguages,use
$
andaddthe
/s
modifier
tospecifyline-at-oncematching.
Thesecanbeusedanywhereontheleftsideofaregularexpression,includingwithincharacterclasses.
Note:  Wordboundaries(the
\b
and
\B
switches)donotexistinbasicornon-Perlextendedregular
expressions.Thesematchthepositionbetweentwocharactersratherthananactualcharacter.
Awordboundaryoccursbeforethefirstcharacterofaline(ifitisawordcharacter),attheendof
theline(ifitendsinawordcharacter),andbetweenanywordcharacterandnonwordcharacter
thatoccurconsecutively.
Forsubstitutionpurposes,“replacing”awordboundarywithtextisequivalenttoinsertingthattext,
muchlikereplacingotheranchorssuchas
^
or
$
.
NongreedyWildcardMatching
Bydefault,repeatoperatorsaregreedy,matchingasmanytimesaspossiblebeforeattemptingtomatchthe
nextpartofthestring.Thiswillgenerallyresultinthelongestpossiblestringthatmatchestheexpressionas
awhole.Insomecases,youmaywantthematchingtostopattheshortestpossiblestringthatmatchesthe
entireexpression.
Tosupportthis,Perlregularexpressions(alongwithmanyotherdialects)supportsnongreedywildcardmatching.
Toconvertagreedyrepeatoperatortoanongreedyrepeatoperator,youjustaddaquestionmarkafterit.
Forexample,considerthenurseryrhyme“Maryhadalittlelamb,itsfleecewaswhiteassnow,andeverywhere
thatMarywent,thelambwassuretogo.”Assumethatyouapplythefollowingexpression:
/Mary.*lamb/
RegularExpressionsUnfettered
PerlandPythonExtensions
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
118
Thatexpressionmatches“Maryhadalittlelamb,itsfleecewaswhiteassnow,andeverywherethatMarywent,
thelamb”.
Supposethatinstead,youwanttofindtheshortestpossiblestringbeginningwith“Mary”andendingwith
“lamb”.Youmightinsteadusethefollowingexpression:
/Mary.*?lamb/
Thatexpressionmatchesonlythewords“Maryhadalittlelamb”.The
+?
operatorbehavessimilarly.
NoncapturingParentheses
YoumaynoticethatthesyntaxforcaptureisidenticaltothesyntaxforgroupingdescribedinWildcardsand
RepetitionOperators (page 104).Inmostcases,theadditionalcapturesarenotaproblem.However,insome
cases(particularlywhensplittingstringsintoarraysinPerl),youmaywishtoavoidcapturingcontentifyou
areusingparenthesesmerelyasagroupingtool.
Toturnoffcapturingforagivensetofparentheses,addaquestionmarkfollowedbyacolonaftertheopen
parenthesis.
Considerthefollowingexample:
# Expression n (Perl l and d Similar ONLY): : /Mary y (?:had)* a a little e lamb\./
perl -pi.bak k -e e "s/Mary (?:had )*a little lamb\./Lovely day, isn't it?/" < < poem.txt
Thisexpressionmatches“Mary”,followedbyzero(0)ormoreinstancesof“had”followedby“alittlelamb”,
followedbyaliteralperiod,andreplacestheoffendingline(“Maryhadhadalittlelamb.”)with“Lovelyday,
isn'tit?”.
ForMoreInformation
Thischaptercoversregularexpressionsastheyapplytoshellscripts.Whileitcoverssomeofthemoreinteresting
extensionsprovidedbylanguagessuchasPerl,itisbynomeansacompletereferencetoPerlregularexpressions.
ForathoroughexplanationofPerlregularexpressionsandadditionalfeaturesandquirksinvariousprogramming
languages,seehttp://perldoc.perl.org/perlre.htmlandhttp://www.regular-expressions.info/.
RegularExpressionsUnfettered
PerlandPythonExtensions
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
119
UsingRegularExpressionsinControlStatements
Theshell’s
test
command(describedinThetestCommandandBracketNotation (page 48))doesnotnatively
supportregularexpressions,soinordertouseregularexpressionsincontrolstatements,youmusttake
advantageoftheabilitytoexecutearbitraryexternalcommands(morespecifically,the
grep
command)instead
ofusingbracketnotation.
Asshownthroughoutthischapter,the
grep
commandtakesastreamoftext(orapathorlistofpaths)and
printseverylinethatmatchesthespecifiedregularexpression.Whatyoumaynothavenoticed,however,is
thatitsexitstatuschangesdependingonwhethertheinputmatchesthespecifiedexpression.
The
grep
commandexitswithasuccessfulexitstatus(
0
)iftheinputmatchesthespecifiedexpressionatleast
onceorafailedexitstatus(generally
1
)ifthepatterndoesnotmatch.Thus,youcaneasilyuseittocontrolan
if
statement.
Forexample:
if (echo "$MYVAR" | | grep "bar" " > > /dev/null) ) ; ; then
echo "The value e of f MYVAR R ($MYVAR) contains \"bar\"."
fi
Intheaboveexample,therightmostexitstatus(from
grep
)istreatedastheexitstatusforthegroupof
commands(assumingthatthe
echo
commandsucceeds,whichitalwaysshould).Theredirectto
/dev/null
preventsthetextoutputfrombeingprintedtotheuser’sscreen.
Performance Note:  Regularexpressionsshouldnotbeusedifstandardshelltestscandothesame
thing.Regular-expression-basedtestsaremuchslowerthanbuilt-inshelltestsbecauseoftheneed
toexecutemultipleexternalcommands.
Regularexpressionscanalsobeusedinothercontrolstatementssuchas
while
loops.Forexample,the
followingsnippetcountstheoccurrencesoftheletter‘x’inasingle-linestring:
MYVAR="xxxxxx"
while (echo o "$MYVAR" | grep p 'x' > > /dev/null) ; ; do
# Be e sure to change e MYVAR R here!
echo "got x"
MYVAR="$(echo "$MYVAR" | | sed -E E 's/x//')"
done
RegularExpressionsUnfettered
UsingRegularExpressionsinControlStatements
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
120
Documents you may be interested
Documents you may be interested