Echo String

How do I use preg_replace() to replace asterisks and dashes in specific lines of a text based input form?
I have a form where the use inputs asterisks and dashes to represent a bulleted list. I’m new to regex so I don’t know how to utilize the preg_replace() function to turn that input into a
$body .= ‘
‘;
$string = $element_7;
echo preg_replace(‘/^([*-]*)/’,'$1′,$string);
print “
- “;
- ” . $string . “
print “
“;
print “
“;
That’s the code but I can’t get it to work! It keeps returning the original text and proceeds to printing it at the top of the screen. Anyway, how do I make this work…I’ve lost all my patience!
This is the code you want:
$string = preg_replace(‘/([*-]*)/’,”,$element_7);
print “
- “;
- ” . $string . “
print “
“;
print “
“;
This is how the preg_replace() function works: it takes a regex as the first parameter, it takes what you want to replace it with as the second parameter, then as the third parameter it takes the original string, then returns the result. So I saved the new string as $string.
The problem with your regex was that ^ means, anything that’s NOT whatever comes after it. So you were saying that you wanted to keep the – and * and replace everything else. But you were trying to replace it with $1 which doesn’t exist so it wasn’t doing anything.
Hope that helps!
“Echo” 12- string acoustic (original)
|
|
ECHO STRING TRIMMER BUMP HEAD KNOB SPOOL ( 4 SLOT ) $18.99 |
|
|
Stihl & Echo string trimmer bump head spring 215603 $4.74 |
|
|
New! Shindaiwa String Trimmer Gear Case Sub Assy 63901-63022, Echo C051000680 $69.00 |
|
|
Carburetor Echo Edger String Trimmer 15mm Intake $28.99 |
|
|
NEW VERI ECHO Weedeater head 3/8” X 20 LH string trimmer SRM Straight shaft,USA $11.99 |
|
|
Carburetor Echo String Trimmer 15mm Intake Carb $28.99 |
|
|
New! Shindaiwa String Trimmer Gear Case Comp. 63000-63020, ECHO C051000480 $79.00 |
|
|
Oregon String Trimmer Line .065″ fits Stihl Echo $7.07 |
|
|
ECHO & MCCULLOCH STRING TRIMMER BUMP HEAD GT2101 GT2102 $30.39 |
|
|
2 Pack Echo 5lb Spool .095 Cross Fire Nylon String Trimmer Line – OEM 316095053 $99.98 |
|
|
New KL650 KWIK / Rapid Loader String Trimmer head fits Echo / Part No. 21560056 $29.99 |
|
|
8 Pack Echo 5lb Spool .095 Cross Fire Nylon String Trimmer Line – OEM 316095053 $407.92 |
|
|
Echo 5lb Pound Spool .095 Cross Fire Nylon String Trimmer Line – OEM 316095053 $52.99 |
|
|
2 Pack Echo 1lb Donut .095 Cross Fire Nylon String Trimmer Line – OEM 311095063 $29.98 |
|
|
Pull Srart Assembly for Unknown ECHO String Trimmer $18.95 |
|
|
Echo 5lb Pound Spool .105 Cross Fire Nylon String Trimmer Line – OEM 316105055 $52.99 |
|
|
2 Pack Echo 5lb Spool .105 Cross Fire Nylon String Trimmer Line – OEM 316105055 $102.98 |
|
|
8 Pack Echo 5lb Spool .105 Cross Fire Nylon String Trimmer Line – OEM 316105055 $407.92 |
|
|
30101652730 ECHO HARNESS RING 30031839330 CHAINSAW STRING & HEDGE TRIMMERS OEM $3.99 |
|
|
Echo 5lb Pound Spool .095 Round Nylon String Trimmer Line – OEM 315095053 $49.99 |
|
|
2 Pack Echo 5lb Spool .095 Round Nylon String Trimmer Line – OEM 315095053 $98.98 |
|
|
8 Pack Echo 5lb Spool .095 Round Nylon String Trimmer Line – OEM 315095053 $375.92 |
|
|
ECHO GT-200 Gas Powered String Trimmer Weed Whacker $51.00 |
|
|
OEM Echo Fuel Cap 13100455830 P021012210 String Trimmer $3.98 |
|
|
NEW Genuine ZAMA RB-K75 CARBURETOR for ECHO A021000740 – Fits Many Models! $51.49 |
|
|
NEW Genuine ZAMA RB-K75 CARBURETOR for ECHO A021000740 – Fits Many Models! $51.49 |
|
|
Zama Carburetor for Echo String trimmer SRM-200 $56.84 |
|
|
Zama Carburetor for Echo String trimmer SRM-210E $56.84 |
|
|
Echo String Trimmer Head knob Left Hand Thread cne_parts_sales 215706 $7.00 |
|
|
ECHO SRM STRING TRIMMER STEEL BLADE GAURD 69900023432 $11.99 |
|
|
ECHO GT-2000 GAS STRING TRIMMER THROTTLE CABLE TRIGGER $11.95 |
|
|
ECHO GT-2000 GAS STRING TRIMMER WEEDWACKER HANDLE $8.95 |
|
|
ECHO GT-2000 GAS STRING TRIMMER WEEDWACKER SHIELD $11.95 |
|
|
ECHO STRING TRIMMER MUFFLER COVER PART # 14587152130, A320000250, A320000251 $1.00 |
|
|
ECHO STRING TRIMMER SHIELD BRACKET {LOT OF 4} PART # 69901840830, C552000110 $1.50 |
|
|
Echo STRING TRIMMER CARBURETOR SRM-280 15mm BORE $37.40 |
|
|
ECHO STRING TRIMMER CLUTCH DRUM PART # 17500506720 FOR SRM300 $16.00 |
|
|
ECHO STRING TRIMMER ADAPTER PLATE PART # 61031340830 FOR SRM200, SRM2200, SRM230 $6.50 |
|
|
ECHO STRING TRIMMER SHIELD BRACKET PART # 69901105330 FOR SRM200, SRM202, SRM302 $3.50 |
|
|
ECHO STRING TRIMMER AIR FILTER PART # 13031040930 FOR SRM2500, 2501, 2502, 3000 $3.50 |
|
|
ECHO STRING TRIMMER OIL SEAL PART # 61041305330 FOR SRM200, SRM202, SRM300 $0.99 |
|
|
ECHO STRING TRIMMER COVER PART # 69621752730 FOR GT2000, GT230, GT2400 $3.50 |
|
|
ECHO STRING TRIMMER SPRINGS {LOT OF 4} PART # P022006710 FORSRM230, 265, 280 $2.50 |
|
|
ECHO STRING TRIMMER GASKET KIT PART # 88900027230 88900027231 FOR SRM250E, 2500 $2.50 |
|
|
ECHO STRING TRIMMER GASKET KIT PART # 88900040630, 88900040631 FOR SRM2000, 2200 $2.50 |
|
|
ECHO STRING TRIMMER INJECT PLUG {LOT OF 6} PART # 61051001930 FOR SRM3000, 400 $8.00 |
|
|
ECHO STRING TRIMMER GASKET/DIAPHRAGM KIT PART # 12310151430 FOR SRM3800 $1.00 |
|
|
Dvorak: The String Quartets $37.77 All products are BRAND NEW and factory sealed. Fast shipping and 100% Satisfaction Guaranteed…. |
|
|
Echoes: The Einaudi Collection $7.42 All products are BRAND NEW and factory sealed. Fast shipping and 100% Satisfaction Guaranteed…. |
|
|
Silk Road Journeys: Beyond the Horizon $10.67 It is a perilous proposition when genres clash–and no such collaboration is more potentially fraught than when improvisation-trained folk musicians sit in with Western classical instrumentalists, who are taught to interpret a printed score. The renowned cellist Yo-Yo Ma has devoted much of his professional life to such intercultural experiments. But the traditions of nations situated along the an… |
|
|
Hitachi CG22EASSLP 21.1cc 2 Stroke Gas Powered Straight Shaft Grass Trimmer (CARB Compliant) $199.99 Includes 21cc Gas Straight Shaft String Trimmer – CG22EASSLP… |
|
|
Poulan Pro PP125 17-Inch 25cc 2-Cycle Gas-Powered Straight-Shaft String Trimmer with Split Shaft $89.99 Optional attachments and a split boom shaft turn the Poulan Pro 25 cc 2-cycle gas trimmer into 6-tools-in-1: trimmer, edger, blower, cultivator, brush cutter, or pole pruner. The straight shaft trimmer features a 17-inch cutting width and dual exit .096-inch diameter cutting line. This tool also includes a durachrome cylinder for extended engine life, heavy duty automatic clutch, Tap N Go dual lin… |
|
|
Tanaka 746570 0.095 x 230′ Quiet Trimmer Line $14.88 Tanaka Part LINE TRIMMER 095 SMALL… |
|
|
In Harm’s Way $0.99 … |
|
|
Danelectro DJ3 BLT Slap Echo Effect Pedal $42.55 The BLT Slap Echo is a real treat Slap Echo Small in size but huge in sound these little pedals really put out the sound and at worldbeating low prices Shower room echos you haven t heard since late 50 s recordings. Slap Echo Pedal. Designed for use with most metal string electric guitars. Mix and repeat controls. 9V battery required (not included). |
|
|
Echo $48.99 Men’s 3.4 oz EDT Spray. ECHO is the new urbane fragrance for men who love change and freedom. A pure clear chord like a breath of fresh air strikes the prelude. Unusual metallic undertones evoke the gleaming steel of a big city while redolent woods spices and suede round off the essence of this creation suffusing it with warmth sensuousness and depth. Leaves skin revitalised and sensuous as a caress. Always with the spirit of the times: ECHO for the urbane trendsetter. |
|
|
ECHO BY ECHO (CD) $26.03 Artist: ECHO Genre: Dance, DJ Release Date: 10SEP2002 |
|
|
Outdoor Research Echo Ubertube $20.95 Outdoor Research Echo Ubertube |