+ Reply to Thread
Results 1 to 7 of 7

Modifying RegEx .Replace pattern

  1. #1
    Registered User
    Join Date
    07-16-2019
    Location
    New Zealand
    MS-Off Ver
    365
    Posts
    44

    Modifying RegEx .Replace pattern

    Hi Excel Forum,

    I have a brilliant macro written by user Jindon which creates fill-in-the-blank sentences with Kanji in column 2. The problem I am having is this macro recognises ALL the kanji in column 2. I am having difficulty modifying this macro to replace just the kanji in each cell adjacent to each sentence.

    The macro is as follows:

    Please Login or Register  to view this content.

    The current output:

    Column A:

    ニワトリの赤く立派なトサカは性別や種類を見分けるときに役立っていると考えられている
    戦争するよりセックスしよう
    この海は浅いから子どもも安心して泳げます。
    彼女は服のセンスはいいが、体型がいまいちだ。

    Column B:

    性別
    セックス
    浅い
    彼女

    Column C:

    ニワトリの__く立派なトサカは__や__類を見__けるときに役立っていると考えられている
    __するより__しよう
    この__は__から子どもも安心して泳げます。
    __女は__のセンス__いが、__型がいまいちだ。


    The desired output:

    Column A:

    ニワトリの赤く立派なトサカは性別や種類を見分けるときに役立っていると考えられている
    戦争するよりセックスしよう
    この海は浅いから子どもも安心して泳げます。
    彼女は服のセンスはいいが、体型がいまいちだ。

    Column B:

    性別
    セックス
    浅い
    彼女

    Column C:

    ニワトリの赤く立派なトサカは__や種類を見分けるときに役立っていると考えられている
    戦争するより__しよう
    この海は__から子どもも安心して泳げます。
    __は服のセンスはいいが、体型がいまいちだ。


    Any help resolving this is much appreciated!

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Modifying RegEx .Replace pattern

    That's simply impossible.
    ニワトリのく立派なトサカは性別や類を見けるときに役立っていると考えられている

    ニワトリの__く立派なトサカは__や__類を見__けるときに役立っていると考えられている

    You are missing bold characters in col.B

  3. #3
    Registered User
    Join Date
    07-16-2019
    Location
    New Zealand
    MS-Off Ver
    365
    Posts
    44

    Re: Modifying RegEx .Replace pattern

    Ah, I see what you mean Jindon. This is just a small snippet of the spreadsheet, which does indeed contain the bold kanji in column B.

    In the original spreadsheet, there are 628 words in column B. Replacing every word from column B in each sentence results in fill-in-the-blank sentences such as "__司が__のお尻を__った翌__、__は会社を____休んだ。"

    I am hoping that no matter how many words are in column B, only the word adjacent in column B is replaced from the sentence in column A.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Modifying RegEx .Replace pattern

    The code is written like that, if it doesn't work as you expect, I need to see your workbook with the result that you wat.

  5. #5
    Registered User
    Join Date
    07-16-2019
    Location
    New Zealand
    MS-Off Ver
    365
    Posts
    44

    Re: Modifying RegEx .Replace pattern

    I have manually changed the first 80 lines in column D to demonstrate the desired output.

    Example.xlsm

    Thank you very much for your assistance with this.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Modifying RegEx .Replace pattern

    So, you want it row by row.
    Your result is inconsistent.
    Just an example.
    1) row4
    ColA 十一ページのばんはクラスでします。
    ColB 二
    ColD __十一ページのばんはクラスでします。
    whereas
    2) row61
    ColA 形容詞は、な形容詞、い形容詞、形容詞の三つに分けられます。
    ColB 形容詞
    ColD __は、な__、い__、の__の三つに分けられます。

    Why?
    If 2) is correct
    Please Login or Register  to view this content.
    Last edited by jindon; 02-05-2023 at 04:50 AM.

  7. #7
    Registered User
    Join Date
    07-16-2019
    Location
    New Zealand
    MS-Off Ver
    365
    Posts
    44

    Re: Modifying RegEx .Replace pattern

    Thank you very much Jindon, this is working beautifully.

    D4 was an error on my part and should have been "__十一ページの__ばんはクラスでします".

    For context, I use these in Anki to test my recall of each word. I have the fill-in-the-blank sentence on the front with a picture to represent the concept and the complete sentence with furigana on the back along with other useful bits of information.

    This is incredibly helpful, thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Regex pattern
    By lynnsong986 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-16-2022, 04:30 PM
  2. [SOLVED] Regex Pattern
    By orange13 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-07-2022, 09:17 AM
  3. [SOLVED] Regex Pattern Matching
    By visualnotsobasic in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-16-2018, 09:56 PM
  4. RegEx - Pattern Matching
    By paularthur90 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2017, 09:16 AM
  5. Need to Define RegEx pattern
    By hmr2662 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-09-2015, 09:24 AM
  6. RegEx pattern
    By capson in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 02-15-2015, 06:57 PM
  7. Regex - establishing a pattern
    By twckfa16 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-30-2014, 11:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1