且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用r将文本(字符串)除以某个字符

更新时间:2023-02-26 11:52:08

您需要更完整地指定日期模式.

## 你的样本数据b = "10/1/2017 这是第一家餐厅.9/30/2015 我很高兴.我是~~.6/20/2016 价格合理.."消息 = strsplit(b, "\\d{1,2}/\\d{1,2}/\\d{4}")[[1]]m <- gregexpr("\\d{1,2}/\\d{1,2}/\\d{4}", b)日期 = regmatches(b, m)[[1]]if(length(Messages) > length(Dates)) { Messages = Messages[-1] }as.data.frame(cbind(日期,消息))

 日期消息1 10/1/2017 这是第一家餐厅.2 9/30/2015 我很高兴.我是~~.3 6/20/2016 价格合理..

How to classify strings using r

My text file is such a structure.

        >cell_c2< 8/30/2017    This location has been closed for a few months. Recently I passed by and attracted by their street sign Teriyaki Grill Open. I gave a try. The cashier was friendly and recommended me to try their most popular Teriyaki chicken box. It came with mixed vege and steamed rice. They have an open kitchen with SS equipment. I could see the chef make grill after my order was placed. I love the teriyaki chicken with white rice. The full box costs $8 after tax. I think it's pretty reasonable for what you get near the University area. The chicken is tasty, tender, fresh, and not-to-sweet. I like this little new place, clean and friendly. Next time I will try their noodle.,         5/5/2014    1 check-in        After avoiding Sono express for five years I thought I'd give it a try to see if it had improved. ??Alas, no better than in 2008. ??The food is edible but for an Asian restaurant, I would place it on a very low tier of quality. ??Paper plates and plastic knives and forks are the norm. ??A 3 item combo seemed overpriced for the quality at $8.50. ??The egg roll was like one at the deli of a supermarket while the mixed vegetable was overlooked cabbage and broccoli with a chicken stock sauce. ??The teriyaki chicken was in small chunks and the meat tasted old. ??Sorry if my review mimics my tip, but, I felt I should review this place to dissuade others from coming here. ??I wish it were good, a quality Asian place would benefit the university neighborhood.Sono Express facadeSono Express facade,         11/10/2015            Updated reviewI regularly stopped by to have *** Pork Chop rice, and I'm a little bit sad that I found out the business has a new owner now.,         10/31/2015    Convenient location, friendly staff.I think I got some chicken with my mirin, but I'm not sure. The sauces were so vinegary I couldn't tell. Did the 3-entree special, cost $8.55 after tax for 3 very small portions of this vinegary meat and a plentiful portion of white rice. I've come to expect value to be an unheard of concept near the U, but this one takes the cake. If I had paid $6 for the meal I'd still be unsatisfied due to the lack of flavor.It's a shame, because this is a prime location for a hole-in-the-wall Asian restaurant.,         10/29/2012    1 check-in        I like this place for a few reasons.It's around the corner from the law school, is cheap and all the breaded/fried meats and fish are pan fried when you order them rather than hours before. ??All the bentos come with a big plate of rice that's always perfectly cooked (fluffy, warm, and almost buttery in texture), some sauteed veggies on the side (usually cabbage, carrots, etc.), and a main attraction--a breaded pork cutlet, a piece of fried fish, chicken drumsticks, etc. ??I can't say enough good things about the fried fish. ??The breading is light, crispy and well-seasoned. ??The fish inside is a garden variety white fish, and it's always piping hot and cooked thoroughly yet still moist and tender. ??I had the beef noodle soup today which is a new offering. ??It was really filling with a ton of noodles and a super rich beefy broth. ??It was dominated by egg noodles, which was fine by me, because I'm a pig for noodles. ??The beef was the star of the dish--it reminded me of a pot roast where it literally melts in your mouth. ??The broth was also impressive. ??My only criticisms are that the bok choy seemed like an afterthought and there wasn't enough broth. ??I wonder if the noodles soaked up quite a bit of broth the longer the soup sat in front of me. ??I've never tried any of the Americanized items. ??I usually stick with the fish bento or the Tonkatsu. ??They used to do a Katsu bowl which had fluffy, almost whipped eggs mixed in with the breaded pork and rice. ??It was my favorite, but they've not offered it the last few times I was in.Probably the thing I appreciate most about this place is that they really don't give a damn about impressing you. ??Take its paper plates and styrofoam cups or leave it. ??They have enough of a consistent Asian student clientele that they don't need to advertise or use actual dishes or provide an especially warm dining experience. ??I come here when I want to be anonymous. ??Most patrons dining in are Asian, while most others pop in for to-go orders.This is not a destination spot by any means, but it's a nice option to have around campus for when you're in the mood for something that's cheap and tastes relatively homemade, if a little boring in variety.Fish bento.Fish bento.Beef noodle soup.  I think this is seasonal during the fall/winter.Beef noodle soup.  I think this is seasonal during the fall/winter.,         10/15/2011    7 check-ins        This hole-in-the-wall place seemed sketchy at first, but alas, I found a nice old Asian couple making simple Asian food for a living here.The food is decent and tastes better than what they serve at the Union over at the University of Utah. The only thing I really recommend here is their two or three combo plates for approximately six to eight bucks. Other than that, there's nothing much here.The seating inside of Sono Express.The seating inside of Sono Express.The windows of Sono Express.The windows of Sono Express.,         3/19/2013    Clean and small restaurant. Great food on Chinese menu!Added an egg and a chicken leg. Delicious!Added an egg and a chicken leg. Delicious!,         8/10/2011    This place is good chice for a hungary student who is looking for sth sweet and like chiness. Its very quite and interestingly there is no music.  I suggest its two and three choices plate. The quality is acceptable but not that good.,         10/8/2009    This place is inexpensive and not that bad. Sure, it's nothing fancy, sure the plates are paper, but hey, the food is decent (not earth-shattering) and cheap!I would recommend this place to anyone who wants standard American-Chinese fair and does not want to spend much!,         5/8/2012    This is probably the worst place I have ever been to. It is expensive if you consider the quality of food they serve and ambience even if you compare it to the regular university hang-outs.The only sauce they have is teriyaki.They serve food in paper plates which still might have been acceptable had the owner/waitress kept her fingers off my food.There are no refills for the drinks.Since they don't appreciate you throwing your leftover drinks in the food garbage bin, you will find a small bucket right next to it, in which you will have to pour your drink. I found that pretty disgusting and was wondering whether they had ever been inspected.I will never go there again in my life. I absolutely hated everything.....in spite of it being right across from the university and being supposedly cheap.,         9/19/2007    First to Review                    Listed in Wanugee 100! Japanese, Wanugee! Salt Lake CitySono Express is your typical Collegetown food place. Cheap and across from campus. In this case, U of U campus, home of the Utes! By cheap, think paper plates and cups! The highest quality thing in here are the disposable chopsticks...they use the better pointed barrel Japanese type that separate at one end, instead of the cheaper flat square ones that are joined the entire length and never split evenly! Such a luxury!Japanese and Chinese Cuisine is their moniker. All of those words are a stretch of the truth. Japanese? There is tonkatsu, tempura, etc, but every dish is served with teriyaki sauce. What does this tell you? Chinese owners! No self-respecting Japanese would run a Teriyaki only place, unless there were no asians for 50 miles to appreciate real asian food. You know all of those Teriyaki places in OR and WA? (you know what I am talking about Portland and Seattle! They are everywhere!) Those are Chinese, Koreans or Vietnamese passing off cheap teriyaki dishes as Japanese food to ignorant non-asians whose only known Japanese food is Teriyaki something. So this abomination has spread to Utah! Actually, the owners are Chinese, I heard them speaking Cantonese, and they didn't know what Donburi was. Half the menu is Chinese which consists of the normal Low Fan oriented dishes you will find at Panda Express at your nearest suburban mall. (Actually, P.E. is a lot better quality!). Hey, but as a starving student, you don't care about quality food, you want your food budget to stretch a long ways so you have more for your beer budget! At least I did, when I was at Uni. (actually, I would bum off my buddies. They liked me so much or felt sorry for me enough that they would invite me to join them for a bite or a brew and help pay!)I digress. Nothing over $10 on this menu. The Shrimp Tempura was served on a paper plate, the diet coke in a paper cup, and the total was under $10. There were 5 shrimp pieces plus veggies, with a batter between real tempura and Jack in the Box onion rings. And the dipping sauce was...you guessed it....Teriyaki!,         8/19/2011    Every time we visit my Alma mater, my family comes to Sono Express for lunch. ??This year we found they added some traditional Chinese dishes. ??They are written in Chinese on the menu board, consisting of Pork barbecue, Lu Eggs, and roasted pork feet. ??We love them, reminds me of the lunch box on-board ***'s trains! ??We also love their fried tempura vegetables and sushi rolls. ??The price is very reasonable and the food is fast.
        >cell_c3<1/15/2016    1 check-in        First to Review        This is a little food stand right outside of Wells Fargo. ??It's adjacent to The Curryer which has been there for years and is delicious and loved by many. ??They opened up recently so I decided to brave the cold weather and go try it out for the first time. I ordered the Bibimbap with Fire Chicken. ??The basic description of Bibimbap is that it comes with some rice, veggies, meat, sauce, and a fried egg. ??You mix it all together and then enjoy. Buldak (the name of the stand) translates to Fire Chicken. I expected the fire chicken to be spicy - it wasn't spicy at all. ??Instead it more tasted like it was cooked in a fire, it had a charred/smoky taste to it. ??I wish that it had been spicier.My deduction for stars is because the meal ended up not being that enjoyable. ??It wasn't my favorite Korean food I've had and it was cold/lukewarm. ??When I walked up to the stand at 11:30 it didn't look like they were quite ready, but I asked if they were open. They said yes, took my order, and then started to prepare my dish. ??I saw the egg and chicken get cooked right in front of me, so it was peculiar that my meal was so cold. ??I think it was because the rice and veggies were cold so when it was all mixed up the temps changed to a colder dish. ??It was also a really cold day outside, but I got my hot meal and walked a couple hundred of feet to work.If you like Korean food, I'd recommend giving this place a try. ??Everything is under $10 and the portions are big. ??Plus there aren't a lot of Korean food options within walking distance nearby.Fire chicken bibimbapFire chicken bibimbap,         4/12/2016    I tried the chicken bibimbop- my egg was cooked all the way through so kind of gross and the chicken wasn't reheated all the way through. Great concept, but fell way too short in execution. I've tried 4x and keep feeling disappointed.
        >cell_c4<        4/1/2017    Soooo good. We had been actively avoiding this place because of its sketchy exterior and now I hugely regret that decision. It's been right down the street and I've been missing out for HOW LONG??!! The interior has been revamped into what is actually a very pleasant atmosphere.We got the spicy seafood bibimbop, beautifully crusty rice and delicious veg and seafood out of a sizzling clay bowl. It could have been spicier but a bit of gochujang brought out by the lovely waiter solved that problem.However, the true star of the show was the LA short rib bulgogi! I am still drooling after the dish is long gone. Perfectly marinated and marbled. So yum. So so yum.Short rib bulgogi and seafood bibimbopShort rib bulgogi and seafood bibimbop,         4/21/2017            Updated review8 check-ins        Another great meal! I got a message that this place will be closing soon. That is too bad cause the food and service was excellent!Pot stickersPot stickersGambitang awesomeGambitang awesomeShort ribShort rib                        See all photos from John C. for Seoul Garden                    ,         2/8/2017    Seoul Garden should absolutely be your Korean BBQ go-to.My boyfriend and I have practically become regulars at this charming family-owned restaurant, thanks to the good food, super friendly service, and well-priced BBQ options. Yun, who has been our server every time we've gone, is so sweet and always makes us feel welcome. She has an awesome upbeat attitude, especially on top of going to school full-time. We pretty much want her to be our best friend.One of the greatest things about Seoul Garden is their a la carte tabletop grill BBQ option that I haven't seen at any other Korean restaurants in Salt Lake. Basically, you can either choose the 2-person Korean BBQ meals that come with rice and side dishes, or you can pick from 6 a la carte meats that don't come with any other sides, but are cheaper (and you get more bbq variety). With the second option, you can also get yummy DIY hot pot with add-on options of veggies, udon noodles, seafood, and more. Our favorite BBQ picks are the marinated short ribs (kalbi), pork belly (samgyeopsal), and marinated beef (bulgogi). Their marinade is delicious! The first time we went we were a little confused about the BBQ options, but Yun explained it all to us, and they've since updated the menu with a chart that goes over the details.Of the other dishes we've tried there, the hot stone bibimbap, kimchi jjigae, and dduk mandu guk were our favorites!Definitely check out this gem, and support a local, family-owned business!Dduk mandu guk, or rice cake dumpling soup. Yummy broth, described by the eater as a great hearty soup.Dduk mandu guk, or rice cake dumpling soup. Yummy broth, described by the eater as a great hearty soup.Side dishes!Side dishes!A la carte tabletop BBQ - 2 orders of short ribs, 1 marinated beefA la carte tabletop BBQ - 2 orders of short ribs, 1 marinated beef                        See all photos from Erin F. for Seoul Garden                    ,         12/9/2016    COMPLETELY CLUELESS is the only way to describe this place. ??I asked what kind of noodles came with soups, where it was not listed on the menu. ??The server had no idea. ??The menu isn't very extensive, how could that be? ??He went to check and, still very unsure, mumbled something about them coming with ramen, so I asked if I could substitute rice noodles. ??I explained that I have a food intolerance and could not have wheat. ??The server then proceeded to recommend vegetarian dishes, which was completely baffling. ??I am not vegetarian nor did I ask anything about vegetarian options. ??When I asked if that was the only gluten free option, he said that he needed to check again. This time he came back saying that I can get a side of rice noodles with any of the soups. ??I pointed out that I still cannot have a soup with wheat noodles in it. ??He asks if I am a vegetarian, which again makes no sense. ??The whole time I have been asking about beef and pork dishes. ??At this point, it is still completely unclear to both me and the server what ingredients are in any of the dishes. ??I ask which dishes are gluten free or can be made gluten free. ?? Anyway, he goes to check again. ??For the same thing. ??And he is incredibly slow moving, so we've now been sitting here for 20 minutes while he figures out how to locomote to the other side of the building.This time he says he can't make any substitutions... ??Why didn't he just say this in the first place?!? ??He also still didn't know what noodles come with anything. ??Unfortunately, we just had to leave at this point due to the complete lack of comprehension on behalf of this simpleminded individual and whoever was serving as the manager on duty at the time. ??It is quite unfortunate that people in hospitality could be so completely ignorant about the food that they are serving.,         10/8/2016    1 check-in        I really wanted to like this place because of the reliable reviews of my fellow yelpers, but I was a little disappointed and here's why. Don't get me wrong, the service and food were good. I just wanted my usual Korean BBQ experience with a little bit of homemade touch. In regards to the Korean BBQ experience, I'm talking about the servers firing up the grill and we cook the meat at our own pace. ??Tongs were provided to pick up our protein and lay them on the grill. ??We ordered the pork belly and the prime beef, both not marinated. ??My friend and I planned to cook a few pieces here and there so it wouldn't overcook on the grill or get cold after a few minutes. ??Well that plan went downhill when the chef from the came to our table and asked us if she can help us cook. ??I wasn't sure what to expect so I said, SURE!. She took our plate and distributed it all over the grill. (Sad face). As I attempt to add some pork belly, she recommended not to. We didn't want to be rude if this was their usually routine, but I didn't really like it. It also felt like they took over our cooking experience and then standing over us was a little uncomfortable at times only because I wanted to catch up with my buddy. I was also expecting a lot more side dishes and wanted some of the items to taste more homemade. ??The broccoli was just boiled with no added flavors. The Kimchee tasted like the ones I've had in the jar. The BBQ sauce provided tasted like the ones I buy for my baked beans. If you need extra lettuce, it's $1.50 more and they give you 6 pieces to start with. The bean sprouts are awesome though.....yay! Like other similar Korean BBQ restaurants in SLC, I think its overpriced for the amount of food you get. I know my review sounds like it should be a 2 star rating, but the restaurant was clean, food was good and staff are friendly. ??I just wish for homemade taste and more of my own hands on cooking experience.Vegetable tempura with soy sauceVegetable tempura with soy saucePrime beefPrime beefIf you need more lettuce, they charge $1.50If you need more lettuce, they charge $1.50                        See all photos from Mylan D. for Seoul Garden                    ,         12/6/2016    1 check-in        Had high expectations coming in hearing great reviews. ??It was good. ??A solid 3.5 stars at best. I thought the servings could be bigger especially at these prices. I could mention a few other Korean joints in town that are similar to prices but serve a lot more food. The ribs and bulgogi were good. ***s were tasty. ??Service was Great! Overall pretty good. ??I just felt there was something missing. ??And I can't quite figure it out. ??Karaoke maybe?Seafood pancakeSeafood pancakeSpicy goodnessSpicy goodnessKorean red wine (chilled)Korean red wine (chilled),         4/25/2017    1 check-in        Great food!! Meat was marinated to perfectly! Plum wine was perfect. Great service. Good place eat hang out and eat.Plum winePlum wine,         1/24/2016            Updated review4 check-ins        I threatened our server if that she did not use my card for payment over my friends that I would leave a bad review. I was kidding, kind of, no really I was definitely kidding. Even if she did not use my card, I would have left a good review! This establishment deserved a bump up from their previous rating because of their black bean noodles (usually only offered during lunch Monday-Thursday but they made it for me on a Saturday evening), their delicious kim chi, consistency in grilled mackerel (no surprise here), excellent service, and seriously how cute the yellow pickled radish was (usually comes with black bean noodles). The only downfall this time around was the sweet and sour chicken. I didn't really enjoy the sauce, it was too sweet and not tangy enough. But overall, this was a pretty solid visit.-Sailor outSweet and sour chickenSweet and sour chickenSpicy pork hot stone potSpicy pork hot stone potBlack bean noodlesBlack bean noodles,         2/11/2017    1 check-in        Great food &amp; amazing service!! We started w/the fried dumplings, then got the marinated beef, spicy pork, spicy octopus &amp; a broth w/their seafood medley! Wow! So yum! All of these dishes were phenomenal &amp; our server Jackson was wonderful! Try it out if you haven't yet! You won't be disappointed!Great food &amp; Amazing Service!  All of these dishes were phenomenal &amp; our server Jackson was wonderful! Try it out if you haven't yet!Great food &amp; Amazing Service!  All of these dishes were phenomenal &amp; our server Jackson was wonderful! Try it out if you haven't yet!We had the fried dumplings, marinated beef to grill, spicy pork, spicy octopus &amp; seafood medley broth!We had the fried dumplings, marinated beef to grill, spicy pork, spicy octopus &amp; seafood medley broth!,         3/30/2017    My husband and I can here for dinner on a Sunday night. We were hungry early so decided to go right when they opened. There were already at lest five parties here before they unlocked the door! My guess is this place gets busy fast. We had the Korean BBQ that we cooked ourselves as well as the bipbimbop bowl. Both amazing. The service was also great and every person that helped us did so with a smile on their face. Definitely a place we will add into our weekend rotations.,         1/4/2017    2 check-ins        I think I've found a new Korean restaurant for me to frequent, because this place was delightful! Our server was very friendly and quick, the food was absolutely delicious, and the place was very open and clean. Plenty of options on the menu, though for those that aren't familiar with Korean fare, more pictures and/or descriptions may be helpful.One thing to note: if you want to order any bbq/grill type of foods, make sure you tell them before they seat you. I saw a table have to get up and move to another side because one guy wanted bbq.,         3/9/2016    1 check-in        ROTD 8/22/2016        I think I'm in love with this place. My husband I stopped in here for dinner for the first time a couple of weeks ago. I was initially skeptical because we were the only customers (granted, it was about 830pm on a Thursday), however that skepticism didn't last long. We started with a bit of soju, which was a very nice treat. It's very difficult to find non-Tyku soju anywhere around (even in the liquor store), but they have a couple of different varieties here. We were overwhelmed with all the tasty sounding choices, but finally settled on the tableside BBQ with spicy squid and pork belly. I'm often worried about overcooking or undercooking my food in this context, but our server made sure everything was cooked properly, and it was absolutely delicious! The sauce was very flavorful (but not devilishly spicy for us, we used the whole thing without a problem). The service was absolutely fantastic. Our server was very helpful with food and drink recommendations and is very enthusiastic about all the stuff they serve. Given the amount of customers there on that particular night, I'm a little worried about this place surviving, so please visit! I want to try all the things on the menu (which is going to take many visits). That won't happen if you don't come eat here too, so please help.,         1/1/2017    Service was...well, great as far as filling up water and getting our food went. ??But was very unfriendly and seemed...annoyed we were there. Yeah, we all felt kind of unwelcome. ??The food was ok. We were a party of 6 and they brought out the tiniest amount of side dishes. We are used to K town in LA where the side dishes are always refilled and plentiful and it just seemed really stingy. ??I guess you have to pay for more?They only have some items on the menu 2 days a week...which sucks cause we came for the black bean noodles and they don't serve those on Sunday. The tofu stew was good. ??The bulgogi was decent, but not the best I've had. ??The decor and atmosphere is a little cafeteria like.,         2/27/2016    1 check-in        I ended up order the Japchae (which was a first for me), and pleasantly surprised. The glassy noodles were tasty along with the sweet potato, mushroom, and whatever else seasoned in this dish. It all came together really well!The staff was very accommodated and even asked us their thoughts on remodeling ideas. The service was certainly topnotch!,        

I want to distinguish day / month / year.

I know there are commands. "strsplit" ,"str_split"

But I do not know how to write day / month / year.

If you categorize it, the data is not what I want.

What should I do? I would appreciate it if you could answer me.

b<-readLines(file.choose()) #My document is a .txt file.
B<-strsplit (crudeCorp,"/")
b<-data.frame(B)
write.csv(B,"tqtqtq.csv")

You need to specify a pattern for dates more completely.

## Your sample data
b = "10/1/2017 This was the first restaurant. 9/30/2015 i'm happy. i'm ~~. 6/20/2016  Prices were reasonable.."

Messages = strsplit(b, "\\d{1,2}/\\d{1,2}/\\d{4}")[[1]]
m <- gregexpr("\\d{1,2}/\\d{1,2}/\\d{4}", b)
Dates = regmatches(b, m)[[1]] 
if(length(Messages) > length(Dates)) { Messages = Messages[-1] }
as.data.frame(cbind(Dates, Messages))

      Dates                         Messages
1 10/1/2017  This was the first restaurant. 
2 9/30/2015              i'm happy. i'm ~~. 
3 6/20/2016         Prices were reasonable..