Following is the string i get after processing the Doc File….
$$JHFIRMPHONE-91$$
$$SYSDATE-4$$
Dear $$RCSALUTATION-5$$,
$$PAPTRANSMITTHANKS-34$$$$IPOWERPACKAGE-56$$$$CASHCARDLOADED-57$$$$CASHCARDTYPE-58$$$$ACTIVATE-59$$$$REFUNDBALANCEDUE-63$$$$FLEXPAY-68$$$$FLEXPAYCONT-67$$
$$REFBALDU$$$$EEXT-73$$
$$RALCASHCARD-64$$
$$ACRCASHCARD-65$$
$$CHECKMONEYCREDITCARD-61$$
$$NOPAYFULL-62$$
$$RAFMEMO-38$$$$RAFMEMOPT2-44$$
$$AMENDED-24$$
$$FORMSSCHEDULES-11$$
$$FORMS_LIST$$
$$FDHANDWRITTENATTACHMENTS-35$$
$$FDATTACHMENTS-26$$
$$FURNISHEDCOPIESKEEP-69$$
$$ESORDEATH-36$$
$$GOLDGUARANTEE-20$$
$$BASICGUARANTEE1-76$$$$BASICGUARANTEE2-77$$$$BASICGUARANTEE3-78$$
$$STONLYOPC-37$$
$$STATE-14$$
$$ST_DATA$$
$$STHANDWRITTENATTACHMENTS-29$$
$$STATTACHMENTS-27$$
$$TAXCOURSE-72$$
$$REWARDTYPE-82$$$$REWARDTYPE2-83$$$$REWARDTYPE3-84$$$$HEALTHBENEFITS-92$$$$HEALTHBENEFITS2-93$$$$HEALTHBENEFITS3-94$$$$HEALTHBENEFITS4-95$$$$HEALTHBENEFITS5-96$$
$$SINCERELY-40$$
$$CLOSING-16$$
$$JHTAXSERVICE-17$$
$$RAFSTARMEMO-45$$
$$RAFSTARMEMO2-97$$
What i want is,i need to get all the text values between $$ and $$.I don’t know how to do this in an efficient way…i want some Regular Expression solution to solve this problem.I have very little knowledge about Regular Expression,so please guys help me in this…any efficient solution besides Regex will also do…thanks in advance…
Here are some regex basics, worth reading up on.
As far as your specific problem is concerned:
The regex matches, two literal
$, then arbitrarily many non-linebreak characters (only as much as necessary) to get to two more$. Since matches cannot overlap, there is no danger of getting extra matches from an ending$$to a beginning$$.A slightly more efficient and usually recommended regex would be:
It basically does the same thing, just the regex internals are a bit different (have a look into “lookaheads”).
In fact, if you can guarantee that the text values will always just contain letters, digits, underscores and hyphens, you can use:
Not also that for all three cases, some people prefer to replace
\$\$with\${2}, but I personally find that a bit unnecessary for two repetitions.