Problem Statement
You are helping to develop a weblog-management system called bloggo. Although bloggo pushes all content to the front end of a website in HTML, not all content authors enjoy using HTML tags in their text. To make their lives easier, bloggo offers a simple syntax called shortcuts to achieve some HTML textual effects. Your job is to take a document written with shortcuts and translate it into proper HTML.
One shortcut is used to make italicized text. HTML does this with the <i> and </i> tags, but in bloggo, an author can simply enclose a piece of text using two instances of the underscore character, '_'. Thus, where a content author writes
You _should_ see the baby elephant at the zoo!
bloggo will publish the following instead.
You <i>should</i> see the baby elephant at the zoo!
Another shortcut serves to render text in boldface, which HTML accomplishes with <b> and </b> tags. Bloggo lets content authors do the same with paired instances of the asterisk character, '*'. When a content author writes the text
Move it from *Receiving* to *Accounts Payable*.
it will end up on the website as
Move it from <b>Receiving</b> to <b>Accounts Payable</b>.
Given a
Definition
- Class:
- bloggoShortcuts
- Method:
- expand
- Parameters:
- String
- Returns:
- String
- Method signature:
- String expand(String text)
- (be sure your method is public)
Constraints
- text is between 1 and 50 characters long, inclusive
- the only characters allowed in text are the alphabetic characters 'a' to 'z' and 'A' to 'Z', the underscore '_', the asterisk '*', the space character, and the punctuation symbols ',', ';', '.', '!', '?', '-', '(', and ')'.
- the underscore '_' occurs in text an even number of times
- the asterisk '*' occurs in text an even number of times
- no substring of text enclosed by a balanced pair of underscores or by a balanced pair of asterisks may contain any further underscores or asterisks
Examples
"You _should_ see the new walrus at the zoo!"
Returns: "You should see the new walrus at the zoo!"
A walrus is a large, blubbery cousin of the seal.
"Move it from *Accounts Payable* to *Receiving*."
Returns: "Move it from Accounts Payable to Receiving."
Notice that a boldface span may enclose several words.
"I saw _Chelydra serpentina_ in *Centennial Park*."
Returns: "I saw Chelydra serpentina in Centennial Park."
One piece of text may include italics as well as boldface.
" _ _ __ _ yabba dabba _ * dooooo * ****"
Returns: " yabba dabba dooooo "
Shortcuts may enclose spaces or nothing at all.
"_now_I_know_*my*_ABC_next_time_*sing*it_with_me"
Returns: "nowIknowmyABCnexttimesingitwithme"
"**XU_h_bm .o QnmNI Y_ -!_ x___i vf_i***VL* s**"
Returns: "XUhbm .o QnmNI Y -! xi vfiVL s"
"O z s(P _I_** **__hA v?qcGGgNX***Fm LL*o _w__Mt _"
Returns: "O z s(P I hA v?qcGGgNXFm LLo wMt "
" ThqV*i* a*E u-, Pa*__yKp__*c e ****FW*q***vb* )"
Returns: " ThqVi aE u-, PayKpc e FWqvb )"
"_ay_) pO__ _ _CqZ_N X_* *. * bqw* HW_W___ ig_.u_"
Returns: "ay) pO CqZN X . bqw HWW ig.u"
"s zL I _ m_**-?* * jC_ _**_F dVOO_ Z__-_._ co Px"
Returns: "s zL I m-? jC F dVOO Z-. co Px"
" t_PlC,_ ____l V); * *Sb* *N Oh**X _p__k T_ h__"
Returns: " tPlC, l V); Sb N OhX pk T h"
"J-**_K __v_ZBn_m ___jD_p __k_S**qK CF*XO-t *(uRa"
Returns: "J-K vZBnm jDp kSqK CFXO-t (uRa"
"t I_vc_m__rf__ q? _st_**_ p_ -****_O _ ul _ _"
Returns: "t Ivcmrf q? st p -O ul "
"__*xsi;*SN** *;J* a_s_**L__C s u*iP * ei;K _x_"
Returns: "xsi;SN ;J asLC s uiP ei;K x"
"l*;w*j*! ZIYOm*__?ROco p_c y-___j*COE* WB _Ce Z_"
Returns: "l;wj! ZIYOm?ROco pc y-jCOE WB Ce Z"
"_q__!__m.sAU P_PS TuE_. _ __* RR*n;oT,, V *l,.*f"
Returns: "q!m.sAU PPS TuE. RRn;oT,, V l,.f"
" H _ T_E _;(d d _*(gT*FWlZM_uF_*V?**;E*B_ _ ; **"
Returns: " H TE ;(d d (gTFWlZMuFV?;EB ; "
"widq;_L_ ElLCP*;*_ nQ_ **J***NJJF ,(YQD?*__**_q _"
Returns: "widq;L ElLCP; nQ JNJJF ,(YQD?q "
" cnfG!_ZtM XQ,_TcW_p_-! dYb* *CH*oj Sv;c*w__F K__"
Returns: " cnfG!ZtM XQ,TcWp-! dYb CHoj Sv;cwF K"
"qh ?W_R_q i**_H! _**__V__Bj*RgprA*GUh __ X* *K(j"
Returns: "qh ?WRq iH! VBjRgprAGUh X K(j"
"z_l_ _gv_N *z* a *c *Yb J k**! E__J_ c_Dr"
Returns: "zl gvN z a c Yb J k! EJ cDr"
"T__l*ghj*v **k_eO)_I* R! .AR*W*Xj*___B_T MQ__ A"
Returns: "Tlghjv keO)I R! .ARWXjBT MQ A"
"**eCSbPB__f**_Z_** iGgM ,_x_ _pmWC A,_** O_iIsY _"
Returns: "eCSbPBfZ iGgM ,x pmWC A, OiIsY "
"**pf_ __b( VR_Dxnq_; k k _RKsQx_Gl?____- w f_ *?*"
Returns: "pf b( VRDxnq; k k RKsQxGl?- w f ?"
"**_eW _o F p_)CZ M K d , wmnfX_*vP* Y* *_!V z_**"
Returns: "eW o F p)CZ M K d , wmnfXvP Y !V z"
" M_ K_ X__j_U_qD Aj*c*lAV)_ EwgK_*DWmW***__"
Returns: " M K XjUqD AjclAV) EwgKDWmW"
"**Gl **ye_YFM_ _ jBRTbNB__sm_f**QMr *D*t _ w_"
Returns: "Gl yeYFM jBRTbNBsmfQMr Dt w"
"r*sb*w_Vn_vJ**gx_y _tX)j d__ - MU __D?kE NZnP-L**"
Returns: "rsbwVnvJgxy tX)j d - MU D?kE NZnP-L"
"* *aYp__fF-** _je,Lj MYl_____ *)L*n**E?VmvI_)! _"
Returns: " aYpfF- je,Lj MYl )LnE?VmvI)! "
"?*c *t** _n_Bq**Dm__***H* a _Z_,___Hz__R_w**,_v _"
Returns: "?c t nBqDmH a Z,HzRw,v "
"_ !_-.*s *rs;. J_n_ Z_ o-nvc)_Pf* *_ ___* *w,"
Returns: " !-.s rs;. Jn Z o-nvc)Pf w,"
"_W_b,Js*Z* m*z*o __ GT(ADX*C zuP*aZ* jfM*i__TA"
Returns: "Wb,JsZ mzo GT(ADXC zuPaZ jfMiTA"
"qUjf_ehyN_qPT*z*uP*FQ *GW)* * *ZO(P** * *! *"
Returns: "qUjfehyNqPTzuPFQ GW) ZO(P ! "
" d_I ?b.iiAFOZ _*q Ne * A __ni*** G p*GfQ* sF*"
Returns: " dI ?b.iiAFOZ q Ne A ni G pGfQ sF"
"* * Kj* *_._* yCV*___S ._*p *_DkU-ow_WYKv__ _ _"
Returns: " Kj . yCVS .p DkU-owWYKv "
";;**nfy****-*M? vNu* _l_ _!HB_* ***h j* *L***yx*"
Returns: ";;nfy-M? vNu l !HB h j Lyx"
" eI*Cc *Z _ j__? __K _*H *M**f b***A *x F m__y"
Returns: " eICc Z j? K H Mf bA x F my"
"it?**l_ p_bi _ Z_lYb I_x _?_ _JN__ _v ,xM_eSa __"
Returns: "it?l pbi ZlYb Ix ? JN v ,xMeSa "
"_m sg _*)**D *W_ _*h*w__XjI lH?a fi_C f I_uh -r"
Returns: "m sg )D W hwXjI lH?a fiC f Iuh -r"
"m _Tnp__C_ (Jl__*;*jXk__*tjeK* *I*?h___kI_ F* ***"
Returns: "m TnpC (Jl;jXktjeK I?hkI F "
"Wz_b_tDN* jag * A_lF_q **Q; E ZE*X;,y(!J*U*B*__"
Returns: "WzbtDN jag AlFq Q; E ZEX;,y(!JUB"
"*BO.*P_QhBp_x** AXR__V*FV*Ken!.**_VL_ *HQ-UMYAx*"
Returns: "BO.PQhBpx AXRVFVKen!.VL HQ-UMYAx"
" _w_y*Ek*EclQ*o -W*_ ?mL_zq*R*i*i**C *m __oqn"
Returns: " wyEkEclQo -W ?mLzqRiiC m oqn"
" _H_ _uJ S _ ko *IvrNBF* ejy_ _m_uc_**xyK_ fZy_"
Returns: " H uJ S ko IvrNBF ejy mucxyK fZy"
"*,G*__. Q*NV* _I_* T *_L Q,iY_ l Gni_d_mX_ h_"
Returns: ",G. QNV I T L Q,iY l GnidmX h"
"_Bw-k, cm _**sN;__V*J(*FU-**_ _!_! _XpmbF***t*"
Returns: "Bw-k, cm sN;VJ(FU- !! XpmbFt"
"_nLbZ_uS_d P_ sl *(***_mV_ V_ .H_s__***knR*,__"
Returns: "nLbZuSd P sl (mV V .HsknR,"
")sB*e?z*GQ f*** C * **Isd*bOs*uN*N BqWZK bC*zz* *"
Returns: ")sBe?zGQ f C IsdbOsuNN BqWZK bCzz "
" i_ _T_R_*c*Hf** p***dL n*?** X,?_X_W** _L _ b**"
Returns: " i TRcHf pdL n? X,?XW L b"
"q_WJ RK q C CZ_F*sDhk!R**i*_UY cM OaW_a*DPd L j*"
Returns: "qWJ RK q C CZFsDhk!RiUY cM OaWaDPd L j"
"_now_I_know_*my*_ABC_next_time_*sing*it_with_me"
Returns: "nowIknowmyABCnexttimesingitwithme"
"__________________________________________________"
Returns: ""
"You _should_ see the new walrus at the zoo!"
Returns: "You should see the new walrus at the zoo!"
"_now_I_know_*my*_ABC_next_me_**sing**it_with_me"
Returns: "nowIknowmyABCnextmesingitwithme"
"Move it from *Accounts Payable* to *Receiving*."
Returns: "Move it from Accounts Payable to Receiving."
"*test;*"
Returns: "test;"
"fdg dd_ sdfs_ , sdfsdf ,"
Returns: "fdg dd sdfs , sdfsdf ,"
"**"
Returns: ""
"**************************************************"
Returns: ""
"a__"
Returns: "a"
"____"
Returns: ""