Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: I need help with writing Regular Expressions and defining Capture Groups

  1. #1
    Junior Member
    Join Date
    Feb 2022
    Location
    Milwaukee
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question I need help with writing Regular Expressions and defining Capture Groups

    When you have time, there's a great app you should try called Find and Replace (FAR) that can be used to search for and replace blocks of code.
    FAR can also be used to rename files. I am using it to rename a bunch of files.

    With FAR you can find and replace "word by word", or you can find and replace with fully-featured Java regular expressions and capturing groups.

    My problem is that I don't know a thing about Java or about writing regular expressions or capture groups. I'm 75. I know BASIC, FORTRAN, DEC PDP-8 assembly language, and just enough Arduino-style C++ to have the appearance of being competent at it.

    When renaming files, FAR has a "Find" field where you can enter a regular expression containing capturing groups, and a "Replace With" field where you enter a replacement string that may refer back to the capturing groups using a backslash (\) followed by the group number.
    When renaming files there is also a check box to ignore the file extension and leave it as is.

    The 1,850 files I need to rename are in this general format:

    Windsor_Beacon_Thu_Feb_8__1926_.jpg

    These are image files of single newspaper pages from Newspapers.com
    Note that the words are separated by underscores, there is no leading zero before the day of the month, and there are 2 underscores before the year and one after.

    I would like to rename the files into this format:

    1926-02-08 Windsor Beacon.jpg

    I'm guessing that the "Find" search string could look something like this but I really don't know:

    Windsor_Beacon_(\w*)_(\w*)_(\w*)__(\w*)_

    I'm also guessing that the "Replace With" replacement string with capturing group numbers could look something like this:

    \4-\2-\3 Windsor Beacon

    This still leaves me with the problem of converting "Feb" to "02" and so forth for all the months.
    If I have to rename all these files by hand it will take me nine+ hours, assuming I live that long.

    Any guidance anyone can give me is greatly appreciated.
    Last edited by John Erbes; February 8th, 2022 at 02:18 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: I need help with writing Regular Expressions and defining Capture Groups

    Sorry, I don't know much about Regex. Try asking the question on this forum: http://www.coderanch.com/forums

    Also posted here: https://coderanch.com/t/749482/java/...fining-Capture
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    John Erbes (February 9th, 2022)

  4. #3
    Junior Member
    Join Date
    Feb 2022
    Location
    Milwaukee
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: I need help with writing Regular Expressions and defining Capture Groups

    Norm,
    Thanks for pointing me toward CodeRanch. They are really a great bunch people willing to bend over backwards to help.
    As it turns out, I was able to look at the regex documentation until I sort of figured it out on my own.
    It was a little difficult since the regex and capturing groups docs all assume you are an intermediate-level Java programmer, which wasn't going to happen for me.
    It's not on my bucket list.

  5. #4
    Junior Member
    Join Date
    Nov 2023
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I need help with writing Regular Expressions and defining Capture Groups

    Navigating the intricacies of Regular Expressions and defining Capture Groups has been a thrilling challenge in my writing journey. Each regex pattern is like a puzzle waiting to be solved, and mastering capture groups feels like unlocking a secret code. The learning curve is steep, but the satisfaction of crafting precise expressions to manipulate text is unparalleled. For those seeking assistance, I stumbled upon a goldmine of support at an Assignment Writing Service (https://essaypro.com/assignment-writing-service). Their expertise has been a game-changer, turning what seemed like a coding conundrum into a rewarding skill set. Embrace the challenge; the knowledge gained is worth the effort!
    Last edited by Johalokjesus; December 5th, 2023 at 03:27 PM.

  6. #5
    Junior Member
    Join Date
    Jan 2024
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I need help with writing Regular Expressions and defining Capture Groups

    While creating regular expressions and defining capture groups, I realized that painstaking work requires precision, especially when it comes to writing nursing papers. In this context, I remembered a service that helps with writing nursing school papers. This highlights the importance of having the right approach and access to resources, whether in the coding world or in nursing education or any other field.

  7. #6
    Junior Member
    Join Date
    Jan 2024
    Location
    Fuglevej 30, 4623, Ejby, Køge Denmark
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I need help with writing Regular Expressions and defining Capture Groups

    Feel free to ask your questions about writing Regular Expressions and defining Capture Groups. Whether it's pattern matching, extracting specific data, or any related queries, the community is here to assist you. Share the details, and let's work through it together! 👩*💻🔍

    --- Update ---

    Hey community! 👋 I'm currently grappling with Regular Expressions and defining Capture Groups in my coding journey. 🤯 Any seasoned regex wizards out there willing to lend a helping hand?

    🤔 Specifically, I'm looking for guidance on [insert specific challenge or question]. If you've got tips, examples, or resources to share, your expertise would be greatly appreciated! Let's unravel the mysteries of regex together. 🚀💻
    Ariana Angel, a seasoned web developer, seamlessly blends creativity with technical prowess. With a profound knowledge of computer systems, she crafts digital experiences that resonate. Ariana stays at the forefront of the ever-evolving internet landscape, consistently updating her skills. Her passion lies in transforming complex concepts into user-friendly interfaces, making her a dynamic force in the world of web development.

  8. #7

    Default Re: I need help with writing Regular Expressions and defining Capture Groups

    Embark on a sensory journey through the groundnut oil mill, where humble peanuts metamorphose into a nutrient-rich elixir. Nestled in the heart of agricultural abundance, this mill is a testament to the versatility and health benefits of groundnut oil. The journey begins with the meticulous sorting and cleaning of peanuts, setting the stage for an extraction process that values purity. Modern milling equipment blends seamlessly with traditional methods, ensuring the preservation of natural flavors and nutritional goodness. The rhythmic hum of machinery fills the air as peanuts are pressed to yield golden-hued oil, capturing the essence of the earth in every drop. The groundnut oil mill stands not just as a processing facility but as a guardian of health, delivering a wholesome product that graces kitchens worldwide. This unassuming mill transforms the ordinary peanut into a source of culinary delight and nutritional vitality.

Similar Threads

  1. Text Processing with Regular Expressions explained in Java
    By JavaPF in forum Java Programming Tutorials
    Replies: 3
    Last Post: February 8th, 2022, 05:16 PM
  2. Regular Expressions
    By NorrinGalan in forum Object Oriented Programming
    Replies: 1
    Last Post: April 12th, 2014, 06:21 PM
  3. use of regular expressions in string.replaceAll
    By nesthead98 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 17th, 2012, 01:24 PM
  4. Web Crawling & Java Regular Expressions
    By Nytol in forum Java Theory & Questions
    Replies: 1
    Last Post: November 18th, 2011, 02:34 PM
  5. regular expressions
    By brad35309 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 5th, 2010, 08:30 PM

Tags for this Thread