• 締切済み

JS ベタ打ち原稿を成型して配列変数に格納する

JavaScript ベタ打ち原稿を成型して配列変数に格納するには? テキストエリアにベタ打ち原稿があります。 これを出力例のように配列変数に格納するには JavaScriptでどういうコードになりますか? 出力例 1. Harrison Gregory - I'm Alone (2:09) ・・・ 51. Adward Hamilton - I Love You So (2:53) ・・・ 100. The Levons - We're Just Friends Now (2:25) [HTML] <textarea id="genkou" cols=100 rows=30 style="display:none"> 1. Harrison Gregory - I'm Alone (2:09) 2. Los Po-Boy & Citos - Trinidad (3:29) 3. Greenwood Rythm Coalition - Guajira (3:34) 4. Bobby Milano - Rags To Riches (2:07) 5. Frank Heppinstall - Sweetheart (3:27) 6. Sonny Holley - I Need Your More (2:49) 7. Spece Long - José (3:19) 8. Dlen Lovers - May I Hide The Pride (2:36) 9. Bernadette - Set Me Free (2:20) 10. Big Guss Jefferson - Will You Be There (2:47) 51. Adward Hamilton - I Love You So (2:53) 52. Heaven All Around Me - Heaven All Around Me (2:39) 53. Keith Powell & The Valets - I Sould Know Better (2:44) 54. Adah Louise Wilson - Too Much (2:10) 55. The Snowmen - Sugar Daddy (2:10) 56. Victorians - I Want To Belong To You (2:19) 57. Jackson Bros - But Still I Do (2:38) 58. Freddie Scott - I Had A Lover (2:41) 59. Avia - Westernize (3:38) 60. Jimmy Dean - Sixteen Tons (2:40) 91. Wee Willie Harris - Little Bitty Girl (2:22) 92. Miller Sisters - Tell Him (2:35) 93. O'jays - Miracle (2:30) 94. Roby Davis - Minor Mad (2:55) 95. Ruth Brown - Walk With Me Lord (2:13) 96. Stand By Me - Stand By Me (3:17) 97. September Jones - I'm Coming Home (2:47) 98. The Tams - Deep Inside Me (2:23) 99. Simon Scott - Tell Him I'm Not Home (2:44) 100. The Levons - We're Just Friends Now (2:25) </textarea>

みんなの回答

回答No.2

>foreach等のループ処理は無用です。 ちがうんです。 分解に使う文字は、通常捨てられるので、 だからforeachで分解に使った文字を追加して表示 しないといけないという理由でのforeachです。 捨てない方式だと、strposの固まりになりますかrね。

retorofan
質問者

補足

>捨てない方式だと、strposの固まりになりますかrね。 そうなります。 ヒント(キーワード)は、先読みアサーション!

回答No.1

まいど! > 100. The Levons - We're Just Friends Now (2:25) 法則が、[0-9]x1~3文字 "."で始まる"(" ~ ")" さらにセパレーター文字として" "があるのが、いいですね。 なので あとは、それを正規表現にするなり、気合分解するなり^^ が!! しか~~し! 要件定義は、曲の番号を分離しないといけないとは指示がない! とすれば")"をトークンとしたexplode / splitで分解しつつ foreach中に、最後に")"を付けて表示するという、 なぞの表示が気合で分解した場合の最小サイズになるかも^^

retorofan
質問者

お礼

ご回答ありがとうございます。

Powered by GRATICA
retorofan
質問者

補足

おっしゃる通り、曲番号の分離云々は無用ですね。 splitで分解してコンソール出力すれば完結します。 foreach等のループ処理は無用です。 成型データを配列変数(songlist)に格納して console.table 出力する場合、 AsarKingChangさんならどんなコードで書きますか?

関連するQ&A

  • JS ベタ打ち原稿を成型して出力するには?

     JavaScript ベタ打ち原稿を成型して出力するには? 未編集の洋楽プレイリストがあります。 これを、次の書式どおりに成型することにします。 [成型後の書式] 2桁の連番_歌手名_-_曲名_(分:秒) or (西暦年) [_:半角空白] <仕様> ・jQuery等のプラグインは不使用のこと ・「連番、歌手名、曲名、演奏時間」が1行ずつのまとまり ・演奏時間の箇所が 西暦年の場合がある ・歌手名、曲名に 次の記号が含まれている場合がある  アンパサンド、半角括弧、アポストロフィ、バッククォート (& ( ) ’ `) 手順1 テキストエリア「genkou」にベタ打ち原稿を貼り付けます。 手順2 実行ボタンを押すと、テキストエリア「result」に成型して出力します。 そうするためには、どのような JavaScriptコードになりますか。 [HTML] <textarea id="genkou" cols="100" rows="30"> 01 - Artie Garr (a.k.a Art Garfunkel) - Beat Love (1959) 02 - Mark Dinning - Loving Touch (2:10) 03 - Petty Booka - Bla Bla Bla Cha Cha Cha (2:28) 04 - Sam Fletcher - I'd Think It Over (2:38) 05 - Untouchables - Raisin Sugar Cane (2:11) 06 - Esther Phillips - Just Say Goodbye (2:18) 07 - Eddie Holland - Jamie (2:23) 08 - Della Reese - Tea For Two (2:13) 09 - Danny Winchell - Por Favor (2:10) 10 - Clyde Otis - Jungle Drums (1:56) 11 - Christine Quaite - Your Nose Is Gonna Grow (2:10) 12 - Martin Bet - I Know A Girl (2:01) 13 - Arthur Alexander - Anna (2:52) 14 - Mickey & Sylvia - Love Is Strange (2:54) 15 - Richard Anthony - Cin Cin (Chin Chin) (3:02) 16 - Sarah Vaughan - Broken Hearted Melody (2:55) 17 - Aphrodite's Child - Rain And Tears (1968) 18 - Nico Landers - Stil In De Straten (2:26) 19 - Ginny Arnell - He's My Little Devil (2:10) 20 - Azie Mortimer - Lips (2:22) 21 - Ava Max - Salt (2019) 22 - Gun`s N Roses - Don't Cry (1991) 23 - Sarah Vaughan - Smooth Operator (2:27) 24 - The Weeknd - Save Your Tears (2020) 25 - Martha Reeves & The Vandellas - Nowhere To Run </textarea> <div> <button id="btn">実行ボタン</button> </div> <textarea id="result" cols="100" rows="10" placeholder="成型後" readonly></textarea> </textarea>

  • 和訳お願いします

    But I know I’ll never let you go Tell me why I can’t stop thinking about you The way you turn me on, and on…… この英文の意味がわかりません わかる方がいれば和訳よろしくお願いします>_<

  • 歌詞の和訳をお願いします

    Don't Turn Around と言う曲なのですが 和訳をお願いします。 (Spoken) I will survive without you... Don't tell me that you wanna leave... Whoa whoa whoa whoa Whoa whoa whoa whoa If you wanna leave I won't beg you to stay And if you gotta go, darling Maybe it's better that way I'm gonna be strong I'm gonna do fine Don't worry about this heart of mine (Spoken) Walk out that door See if I care Go on and go, but Don't turn around 'Cause you're gonna see my heart breaking Don't turn around I don't want you seeing me cry Just walk away It's tearing me apart that you're leaving I'm letting you go But I won't let you know... I won't let you know. Whoa whoa whoa whoa Whoa whoa whoa whoa I won't miss your arms around me Holding me tight (Holding me tight) And if you ever think about me Just know that I'll be alright (I'll be alright) I'm gonna be strong I'm gonna do fine Don't worry about this heart of mine (Spoken) I will survive I'll make it through I'll even learn to live without you Don't turn around 'Cause you're gonna see my heart breaking Don't turn around I don't want you seeing me cry Just walk away It's tearing me apart that you're leaving I'm letting you go But I won't let you know... I wish I could scream out loud That I love you, I wish I could say to you Don't go........ (Spoken) As he walks away He feels the pain getting strong People in your life They don't know what's going on Too proud to turn around He's gone Don't turn around 'Cause you're gonna see my heart breaking Don't turn around I don't want you seeing me cry Just walk away It's tearing me apart that you're leaving I'm letting you go, Baby don't turn around Whoa whoa whoa whoa Don't turn around Whoa whoa whoa whoa Just walk away Whoa whoa whoa whoa It's tearing me apart that you're leaving I'm letting you go Don't turn around Whoa whoa whoa whoa Don't turn around Whoa whoa whoa whoa Just walk away Whoa whoa whoa whoa

  • 和訳お願いします

    「What do you do in your life? I'm a student Tell me about you if you want..」 お願いします

  • 歌詞の和訳をお願いいたします。

    I'll bring my love to you… I'll bring my love to you I've been stood up messed around and take for a fool but next time 'round I'm gonna change the rules and I don't care about the things that people say it's you I think about each and every day it's much too late for you to change your ways I can't keep holding on expecting you to stay when you're all alone and if you're feeling down call me I'll be around Whenever you need somebody I'll bring my love to you you don't have to say you love me I just wanna be with you Lost inside your love is where I wanna be I'm just asking you to spend some time with me time and time you say you wanna be free and you can have some fun that's okay with me you will never know just how good I feel the joy inside of me makes me feel so real when you're all alone and if you're feeling down call me I'll be around Whenever you need somebody I'll bring my love to you you don't have to say you love me I just wanna be with you whenever you need somebody I'll bring my love to you you don't have to say you love me I just wanna be with you I'll bring my love to you (I just wanna be with you) I'll bring my love to you (I just wanna be with you) It's much too late for you to change your way I can't keep holding on expecting you to stay when you're all alone and if you're feeling down call me I'll be around Whenever you need somebody I'll bring my love to you you don't have to say you love me I just wanna be with you whenever you need somebody I'll bring my love to you you don't have to say you love me I just wanna be with you Whenever you need somebody I'll bring my love to you you don't have to say you love me I just wanna be with you

  • 歌詞でdoesn´tを don´tに変える意図は?

    例えば「The Way I Are」では、 "It don´t matter  ´cause I´m the one that love you best" そして 「Streets of London」では、 "So how can you tell me you´re lonely, and say for you the sun don´t shine?" というくだりがあります。 このようにdoesn´tを don´tに変える意図は何でしょうか。単にリズムの問題でしょうか。 よろしくお願いします。

  • YOU LIKE THE MOST AND WHAT YOU LIKE ABOUT THEM.

    ちょっとわかりづらいです。うまく訳せないので訳を教えてください。メールのへんじなんですが、 YEAH I TOOK THE PHOTOS ITS ONE OF MY PASSIONS IM AN ALL AROUND ARTIST AT HEART. FOR REAL ANYTHING THAT HAS TO DO WITH ART I LOVE,AND THANK YOU FOR THE REPLY AS WELL. CAN YOU TELL ME WHAT PICS. YOU LIKE THE MOST AND WHAT YOU LIKE ABOUT THEM. WORD OO(名前) そうだよ私が撮った。私のジョウネツのひとつ?????...わかりません返事をありがとう。何の写真かしえてくれる?わなたが最もすきなのと... すみませんこんな感じでしか分かりませんでした。教えてください

  • 【古めのR&B】ヒット曲、名曲、オススメ曲

    80's~90'sのR&B、SOULで昔流行ったもの、オススメのものがあったら教えてください。 ベタなもので構わないのですが、クラブ等では聞いただけでは曲名・アーティスト名がわからないので、探すのに苦労しています。 例えば ・Around The Way/ Really Into You ・Joy Enriquez/ Tell Me How You Feel ・Kut Klose/ Lovely Thing ・En Vogue/ Give It Up, Turn It Loose ・Lisette Melendez/ Goody Goody ・Elisha La'verne/ I Maybe Single ・The Braxtons/ Slow Flow ・DeBarge/ I Like It こんな感じの曲で思い当たるものがあれば教えてください。

  • なぜgoではなく、getなのでしょうか?

    私は、あれから「天国に行けなかった A子、お母さん、お父さん、ごめんなさい」とはもう言わないと、貴方に約束したのでした。 約束、きちんと守っていますよ。 何故なら、貴方が「お姉さんも,お母さんも,お父さんも、天国にいるはずだよ。」と言ってくれたから・・・。 「A子が亡くなったとき、『もういいです。』という権利があったのは、お母さんとお父さんだけだったはずだよ。」と言ってくれたから・・・。 And… I have been keeping my words, you know the words I told you that I would never say, “A子, mom and dad, I am sorry that you could not get to heaven.” I could do this because you taught me that my sister, mom and dad are already resting in heaven. You also made me realize that my mom and dad are the only ones who could decide and tell the doctor, “You may stop the cardiac massage.” 「天国に逝けなかった」はcould not go to heaven ではなく、could not get to heavenが良いでしょう、と英会話教室の先生に言われました。 天国に「行く」のではなく、「天国へ旅立つ(得る)」という意味でしょうか? ご解説をお願いいたします。

  • 和訳お願いします。

    かなり長いですが、よろしくお願いします。 I want to you listen, and pay close attention for what I’m going to say. If you didn’t have time today for some “You, and me time” You haven’t made the time. Quite obviously you say in terms that apparently I’m important, that you love me, etc. It depends on you to make the time, as for me I do make time for you. When I’m not free I’ll tell you, if I am I’ll tell you. I’m telling you this because I love you. All I’m asking you is to make some time for us. FaceTime especially, if you don’t want to that’s fine. Just say something. I can’t read your mind.

専門家に質問してみよう